Quick question. I've got a bunch of inherited classes like so:
Object_____
| |
Actor Item
|
|_______
Human Animal
I also have a class called Room, defined like so:
class Room
{
Object * addObject (unsigned long _UID, string _name);
map<int, Object *> objects; // A map containing the Objects within the room
}
What I'd like to do is make the function addObject()
able to instantiate any type of the Object classes, something like Room.addObject(Object::Actor::Human)
, which would then add a Human Object to my list of Objects in the Room. They all have the same constructor arguments, if that helps. Is there any way to do this in C++?