If I have a base class with some pure virtual functions
and 2 derived classes which have their own additional member functions how would I iterate over a list of these and only use the ones that are of a certain derived class?
for example.. If i have Vehicle class , and 2 derived classes Car and Bike.
I create a list
now only Car has the drive() member function... what would be the cleanest way to iterate over the list and only access the drive() function for which are of type Car (ignoring the bikes which dont have drive() )..Code:list<Vehicle*> myrides;
( or am I doing OOP wrong? lol)