Original Post
hello, im having a little trouble getting something to work, and i have no clue why it isnt working . . . becasue it should be working. anyways i have a member function which returns a pointer to a base class then i want to find out which class its pointing to by using typeid then push_back the proper vector. it looks like this. CObject *newObject = factory->getObject(sObjectName); if (typeid(newObject) == typeid(CFloor)) v_Floor.push_back(*(dynamic_cast < CFloor * > (newObject))); if (typeid(newObject == typeid(CScenery)) // . . . delete newObject; the problem is that its never pushing back the object, which means the type of newObject is never CFloor or the other object types i have. factory->getObject(sObjectName) will call this . . . _mCObject::iterator i; i = prototypes.find(key); CObject *newObject = new CObject (*(i->second)); if (i == prototypes.end()) // report error return newObject; i should note that _mCObject is typedef'ed as std::map < std::string, CObject * > and prototypes is a map of CObject pointers when i say // report error i basically have a function call there displaying a messge box and logging an error . . . which never happens so im not trying to get an invalid key. so im confused why this isnt working? what is wrong with this . . . if (typeid(*newObject) == typeid(someObject)); also i should note that factory->getObject(name) will return one of the objects im testing for. the typeid fails for all of the objects. anyways, if anyone could help me out i would appreiciate it. thanks in advance. [edit] CObject *newObject = new CObject (*(i->second)) . . . this line just struck me . . . im pretty sure this is right in that im initializing a newobject with the value pointed by the iterator i? [/edit] [edit] ok (*(i->second)) im pretty sure is correct but for some reason when *newObject is pointing to a floor object its name is 7CObject and CFloor is 6CFloor . . . first of all where are these numbers comming from? and the name of a base class pointer type should be of the class its pointing too shoudnt it? [/edit] [Edited by - ekrax on November 8, 2004 10:03:39 PM]