我想調試我的應用程序,我不斷收到此錯誤,我不知道如何解決它。在調試過程中,我發現錯誤的地方在於函數parseObjects。它還調用創建遊戲對象工廠是如下功能...異常拋出0x00007FF746DA221B SDL_game.exe:0xC0000005:訪問衝突讀取位置0xFFFFFFFFFFFFFFFF
GameObject* GameObjectFactory::create(std::string typeID) { std::map<std::string, BaseCreator*>::iterator it = m_creators.find(typeID);
if (it == m_creators.end())
{
std::cout << "could not find type: " << typeID << "\n";
return 0;
}
BaseCreator* pCreator = (*it).second;
return pCreator->createGameObject();}
這一點,調用一個造物主對象後,成功地加載參數加載功能,但是,當它試圖將對象推回到向量中,它會收到上述錯誤。
異常拋出0x00007FF746DA221B SDL_game.exe:0xC0000005:訪問衝突讀取位置0xFFFFFFFFFFFFFFFF。
...
e->Attribute("x", &x);
e->Attribute("y", &y);
e->Attribute("width", &width);
e->Attribute("height", &height);
e->Attribute("numFrames", &numFrames);
e->Attribute("callbackID", &callbackID);
e->Attribute("animSpeed", &animSpeed);
type = e->Attribute("type");
textureID = e->Attribute("textureID");
GameObject* pGameObject = TheGameObjectFactory::Instance()->create(type);
pGameObject->load(new LoaderParams(x, y, width, height, textureID, numFrames, callbackID, animSpeed));
pObjects->push_back(pGameObject); // fails on this line ???
}`
調試器進入這一行向量... bool _Inside(const value_type *_Ptr) const { // test if _Ptr points inside vector return (_Ptr < this->_Mylast() && this->_Myfirst() <= _Ptr); }
任何幫助和建議將不勝感激...