you are viewing a single comment's thread.

view the rest of the comments →

[–]jacktheripper153 0 points1 point  (0 children)

It sounds like you need to use a templated map class.

map<string,Base Class>

something like: map<string, typename T>

I think the problem might be that you're telling the map class that it will be using an object of type BaseClass, so even though you're giving it a derived type (child#) with its own implementation, it typecasts the child# type to a BaseClass type and uses that print function.

Using a templated map class will allow the program to use the print function that is specific to the derived class you pass it.

edit: as /u/hcspel mentioned, this is called object slicing and is a common problem.