Looking for some advice regarding the following hierarchy structure:
I'm storing base class pointers in a std::list in my program:
Is it possible for me to use Pure Virtual functions in the base class?
virtual int getMPG() = 0;
Seems fine, as all derived types have an _mpg data member.
But, if I use:
virtual int getNoOfDoors() = 0;
I am having problems as Boat objects don't have a _noOfDoors data member. Only those derived from Car do.
So I am wondering, is it not possible for me to use Pure Virtual functions in the base class?
I am accessing all the objects in my program through base class pointers you see.
How does one normally handle this hierarchy?
Thanks very much for any advice!