所以我的代码中有以下内容:
Window.hpp
class Window {
struct windowMap {
SDL_Window* window = 0;
const char* title = 0;
int width;
int height;
int flags;
};
typedef std::map<std::string, windowStruct*> windowMap;
windowMap* m_windowMap;
};
Window.cpp
bool Window::init() {
m_windowMap = new windowMap();
(...)
};
SDL_Window* Window::getWindow(std::string id) {
windowMap::const_iterator keyValuePair = m_windowMap->find(id);
// check if the ID was found
if (keyValuePair != m_windowMap->end()) {
return keyValuePair->second->window;
}
SDL_LogError(ERROR, "Could not get window");
return 0;
};
现在Intellisense根本不会抛出任何错误,编译器也没有,但是当我运行程序时,我得到一个未处理的异常错误抛出:
Unhandled exception at 0x/*Quite a long address here*/ in SDL2-CutePlanet.exe 0xC0000005:
Access violation reading location 0x/*Quite a lot of 'F's here*/
罪魁祸首似乎是getWindow();
,但我不明白并知道是什么导致它绊倒?
有什么想法吗?