C++ programming help

so, Ive searched and searched and cant find anything about an error im having (I’m probably not searching in the right places or using the right keywords:yikes:). the error says:

      undefined reference to `vtable for Robot'

it occurs in two places:
here: class Robot: public SampleRobot
and then at the end closing bracket from when i define the encoders.

any help is appreciated :smiley: :smiley: .

I’d need full code to know for sure, but I suspect this is due to something which should be commented out, but isn’t?

Search your codebase for the string “vtable for Robot” and see if you’re either missing comments, quotes, etc.

FYI, “undefined reference to” is usually the linker saying “I see you have some code object name defined, but I can’t figure out where it’s declared”… I find it weird that it would pick up a whole string like that, so I might be off in the weeds here…

This is not likely to be something named “vtable” in their code. A vtable is used by the compiler to keep track of all the virtual (that’s where the “v” in “vtable” comes from) functions and related parts that make up a class.

Hmmm, it appears I was off in the weeds myself. I suppose that’s what happens when I attempt to answer a C++ question when it’s not my first language…

http://stackoverflow.com/questions/3065154/undefined-reference-to-vtable and the linked https://gcc.gnu.org/faq.html#vtables have some info, but it’s not stuff I’m super familiar with…

thanks for the help guys. i’ll keep looking around then i’ll share what i find with you guys for future references.

This error often shows up when you’ve forgotten to define virtual methods. In this case, since your Robot class inherits from SampleRobot, you should have definitions for at least one of RobotInit(), Disabled(), Autonomous(), OperatorControl(), Test(), or RobotMain(). If you’ve defined some of these, make sure they’re spelled/capitalized correctly and are defined inside the robot class (or qualified, e.g. with “void Robot::Autonomous(){…}”).

If that doesn’t help, it would be helpful if you could post your code somewhere (or at least a portion that reproduces the issue).

i’ve figured out the error…well…one of the mentors did…

 the problem was that something was remmed out and it was still reading as if that code was there, which was duplicating the code we had above it.
 
 thanks for all your help!!:D ::rtm:: ::rtm::