I'm facing the following problem.
I implement parent Class - Vehicle, it has some derived classes, one of them - FastVehicle.
In the program I need to store a Vector of Vehicle* pointers. the pointers may point to Vehicle objects or to FastVehicle objects as well.
1) I want to be able to call the method print() for every object in the vector. The problem is that in case of FastVehicle I also want to tranfer a parameter to the function, I need to call a function with signature:
void print(int a)
I know a little bit about the virtual function mechanism, but according to my knowledge it works only if both functions have the same signature.
I would like to hear suggestions, about how to work it out.
2) In addition in the derived class FastVehicle has some unique function that it doesn't share with the parent class Vehicle. It performs a task that should be performed only for FastVehicle objects. What is the cleanest way to achieve this? I thought maybe to implement "empty" virtual function in the parent class Vehicle and implement the "real" task inside an overriding method of FastVehicle
Maybe someone can suggest a better solution.
thanks