如果用map类的iterator指针

来源:百度知道 编辑:UC知道 时间:2024/06/07 20:47:56
自定义类 SceneNode

typedef std::map<String, SceneNode*> SceneNodeList;
typedef SceneNodeList::iterator Iterator;

函数遍历
for (Iterator i = m_sceneNodes.begin(); i != m_sceneNodes.end(); ++i)
{
i->FrameMove(fElapsedTime);
//调用不到, 报'FrameMove' : is not a member of 'std::pair<_Ty1,_Ty2>'
((SceneNode*)&i)->FrameMove(fElapsedTime);
//这样转换数据会出错
}

map的 iterator里面是个pair类, pair并不直接是内容, 这里面还有一层关系呢

i->second.FrameMove(...)

没用过的容器别直接就用, 先看看msdn上的例子就能知道了