Pitfall: Omitting the Definition of a Virtual Member Function
It is wise to develop incrementally. This means code a little, test a little, then code a little more, and test a little more, and so forth. However, if you try to compile classes with virtual member functions, but do not implement each member, you may run into some very-hard-to-understand error messages, even if you do not call the undefined member functions!
If any virtual member functions are not implemented before compiling, then the compilation fails with error messages similar to this:
Undefined reference to Class_Name virtual table.
Even if there is no derived class and there is only one virtual member function, but that function does not have a definition, then this kind of message still occurs.
What makes the error messages very hard to decipher is that without definitions for the functions declared virtual, there will be further error messages complaining about an undefined reference to default constructors, even if these constructors really are already defined.
Of course, you may use some trivial definition for a virtual function until you are ready to define the "real" version of the function.
This caution does not apply to pure virtual functions, which we discuss in the next section. As you will see, pure virtual functions are not supposed to have a definition.