我在使用dynamic_cast 时遇到问题。我刚刚编译了我的项目并在调试模式下测试了所有内容,然后我尝试在发布模式下编译它,我已经从调试模式复制了所有配置,除了现在的优化参数 /o2,(在调试时我将其设置为 /od)项目已编译,但当它开始加载我的资源时,我在此处的代码段中遇到异常:
for(int j = 1; j < i->second->getParametersNumber();j++)
{
CCTMXTiledMap* temp = CCTMXTiledMap::tiledMapWithTMXFile(i->second->As<string>(j).c_str());
CCTMXLayer* ret = NULL;
for(NSMutableArray<CCNode*>::NSMutableArrayIterator l=temp->getChildren()->begin();!ret && l!=temp->getChildren()->end();l++)
ret = dynamic_cast<CCTMXLayer*> (*l);
t1.first = ret;
templates[i->first].second.push_back(t1);
templates[i->first].second.back().first->retain();
}
代码中没有任何变化,当我检查调试器时,类中的每个变量都是它应该的样子,但动态转换抛出 std::__non_rtti_object。我做错了什么?我正在使用 cocos2d-x ,我没有足够的声誉来添加该标签!
Does CCNode
有虚函数吗? temp->getChildren()->begin() 的所有元素都是真的吗CCNode
s? Does temp->getChildren()
返回参考?后者尤其阴险:你称两者为temp->getChildren()->begin()
and temp->getChildren()->end()
. If getChildren()
返回一份副本,您正在获取begin
一份副本和end
另一个副本。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)