Say I have a member function that creates a new object and places it into a data structure (in this case a map) in the class:
Class A
{
std::map<std::pair<int,int>, BaseClass*> store;
//...
public:
void createObject(?a?)
{
BaseClass* temp = new ?a?;
//place in map...
};
};
Where ?a? is an argument that can be used to create an object that can be a number of different classes derived from BaseClass. The only way I can think of doing this is by making ?a? an int, and manually typing each type into a switch statement.
Use a member function template. In the context of your example:
Invoke with:
Where
ais an instance ofA, andBis a type derived fromBaseClass.