puzzlecracker said:
I was interested of whether it is needed, for you cannot create an
object of an abstract class, so having the definition appears to be an
exercise in futility.
Actually, I see one intuitive explanation, that are objects of
subclasses should have identical implementation of a method in the base
class... is it a valid case, are there more cases where it is needed?
thanks.
Even if only a large portion (not all) of your derived classes are
going to use the same implementation, giving that definition in the
base class will save you from having to define it for each of those.
For example, I'm working on a set of Windows GUI wrapper classes.
Each window class uses a completely different method for processing
messages from the OS, so I've declared a pure virtual function in
the base class for that. On the other hand, they almost all, with
a few exceptions, use the same method for repositioning and resizing
when their parent window changes, so I put that implementation into
the base class and just override it in the few cases where it needs
to be different.