If you are using GCC to compile your code, chances are that sooner or later you will run into that particular linker error. The problem is really quite easy to fix, you just have to know what the problem is.
So here is the reason for your troubles: Somewhere in the class that is mentioned in the error message, you have a virtual function for which there is no implementation. You basically declared it, but didn't write a function body for it. So first you need to find out which one is the cause. The simplest way to go about this is to go through your list of virtual functions in the class declaration and then check if you implemented it. Don't forget any virtual destructors and virtual functions from the base class that you are overriding, since the C++ standard does not require you to repeat the virtual keyword in the derived class.
I really wish GCC would spit out a list of the functions that cause the problem – but for now we have to live with a message that is not very descriptive.
Once you have found the culprit, you have two options: Either implement it (an empty implementation will do), or make it purely virtual by adding "=0" to the end of the declaration in the header file.
If you still get the error, you may have mutiple functions that are non-purely virtual and not implemented. Or you just forgot to compile the source file where the implementation is located, or you didn't link with the corresponding object file.
Friday, May 1, 2009
Subscribe to:
Posts (Atom)