【发布时间】:2016-08-25 08:53:06
【问题描述】:
我的目标是查找 Key(objName)(如果存在)然后返回值。
GameEntity * GameEntity::FindInContents(string objName)
{
for( map<string, GameEntity*>:: iterator iter = contents.begin(); iter != contents.end(); iter++)
{
if(contents.find(objName)== contents.end())
return (iter->second);
else
return NULL;
}
}
但是当我运行代码时,它把我带到了
/** There is also a templated copy ctor for the @c pair class itself. */
#ifndef __GXX_EXPERIMENTAL_CXX0X__
template<class _U1, class _U2>
pair(const pair<_U1, _U2>& __p)
: first(__p.first), second(__p.second) { }
#else
我不明白这是什么问题。提前致谢!
【问题讨论】:
-
与您的问题无关,我认为您的意思是
contents.find(objName) != contents.end()...
标签: c++ for-loop dictionary iterator find