请各位帮忙看看,奇怪的问题
typedef map<string,pdata *> KeyType;
KeyType Keys;
bool GetData(const string key,pdata & p)
{
KeyType::iterator it;
it=Keys.find(key);
if(it==Keys.end())
return false;
obj=(*it).second;
return true;
}
上面的函数返回时 p=NULL; 为什么?
改为下面则可运行.(在类pdata中重载了operator =)
bool GetData(const string key,pdata & p)
{
KeyType::iterator it;
it=Keys.find(key);
if(it==Keys.end())
return false;
obj=* ((pdata *) (((*it).second)));
return true;
}