这个函数完全正常,或者编译器/调试器告诉我
void GUIManager::init(ToScreen* tS)
{
toScreen = tS;
loadFonts();
GUI_Surface = SDL_SetVideoMode( toScreen->width, toScreen->height, 32, SDL_SWSURFACE );
components.push_back(&PlainText("Hello, World!", font, -20, -40));
}
Run Code Online (Sandbox Code Playgroud)
在这里,第一个函数调用引发访问冲突错误.调试器没有显示任何问题.我没有机会调试组件[0],因为程序在这里停止.
void GUIManager::draw()
{
// This line here is the problem
components[0].draw(GUI_Surface);
// This line here is the problem
SDL_BlitSurface(GUI_Surface, NULL, toScreen->Screen_Surface, NULL);
}
Run Code Online (Sandbox Code Playgroud)
如果需要,这是我的'组件'
boost::ptr_vector<GUIComponent> components;
Run Code Online (Sandbox Code Playgroud)
如果需要任何其他代码,请告诉我.也许是PlainText或GUIComponent