Hi there,
Looking for some advice regarding the following hierarchy structure:
http://i40.tinypic.com/9a1us0.jpg
I'm storing base class pointers in a std::list in my program:
list<Vehicle*>mylist
Is it possible for me to use Pure Virtual functions in the base class?
For example:
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!
:)