When building my C++ program, I\'m getting the error message
undefined reference to \'vtable...
What is the cause of this probl
The GNU C++ compiler has to make a decision where to put the vtable
in case you have the definition of the virtual functions of an object spread across multiple compilations units (e.g. some of the objects virtual functions definitions are in a .cpp file others in another .cpp file, and so on).
The compiler chooses to put the vtable
in the same place as where the first declared virtual function is defined.
Now if you for some reason forgot to provide a definition for that first virtual function declared in the object (or mistakenly forgot to add the compiled object at linking phase), you will get this error.
As a side effect, please note that only for this particular virtual function you won't get the traditional linker error like you are missing function foo.