--- Tom Browder <tom.browder@xxxxxxxxx> wrote: > On Dec 1, 2007 9:34 AM, Michael Sullivan > <michael@xxxxxxxxxxxxxxxx> wrote: > ... > > The virtual destructor is there because g++ was > giving me a warning > > about setCurrentSprite(int), which will be > implemented in classes Ally > > and Enemy - both descended from Character. I've > commented out the > > virtual destructor in character.h and used your > Makefile with the > > following output: > > Then problem is Character needs to have the virtual > function defined, > even if it does nothing. So: > This is true only if the class is not abstract, but then there is something wrong with the design if there is to be a noop function. If it can properly be used as an abstract base class, then declare the virtual function in question to be a pure virtual function, as in: virtual void foo(int) = 0; But this will introduce compile time errors if there is an attempt to instantiate it, in which case a choice is to be made as to whether or not the class can function as an abstract base class. If it should not be abstract, then something is wrong with the design if there is a function that is merely a no-op stub. If it should be abstract, then the calling code that tries to intantiate it is broken. The practice of making the destructor virtual is a good one, especially since the OP expressed the intent of deriving a number of classes from the class in question. Ted