I try to create a map with MyID (ULONG) and pointers to CMyBaseClass ( or even void pointers). The code will compile and run fine, however when I check the content of the map, I got garbage. I have spent a couple of days on this one, if anybody can help, I really appreciate. Here is the code snippets:


#include <map>
typedef std::map< ULONG, CMyBaseObject*, std::less<ULONG> > MYID2MYBASEOBJECT;
typedef MYID2MYBASEOBJECT::iterator MYID2MYBASEOBJECTIT;
......
MYID2MYBASEOBJECT m_mapIDToObject;
......
CMyDrivedObject::MyFunction()
{
......
m_mapIDToObject.insert( MYID2MYBASEOBJECT ::value_type(MyID, (CMyBaseObject*) this) );

//My Test Code
MYID2MYBASEOBJECTIT MapIt = m_mapIDToObject.find( MyID );
CMyBaseObject* pObject = NULL;
pObject = (CMyBaseObject*) (*MapIt).second;
//End of Test Code
}



I am desperated, please help.