私の目標は、存在する場合はキー(objName)を探して値を返します。私は、コードを実行したときにmap :: findを使用してキーを見つけ、値を返します
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
に私をもたらします。前もって感謝します!
無関係の詳細についてはhttp://en.cppreference.com/w/cpp/container/map/findを参照してください、私はあなたが意味だと思う 'contents.find(objNameに)= contents.end()' .. –