I am getting a access violation error when I run my program. I am using Visual C++ 2010. The compiler is giving me this error:
First-chance exception at 0x00291709 in RobotWars.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd.
Unhandled exception at 0x00291709 in RobotWars.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd.
I'm new, so this looks like Greek. My compiler is pointing to this code:
The .h file for GameDrawer:Code:void GameDrawer::setLevel(Level* level) { m_currentLevel = level; }
The function that the compiler is pointing to is invoked in the Game object's constructor (with related function definitions):Code:#ifndef GAMEDRAWER_H #define GAMEDRAWER_H #include "Level.h" #include "Game.h" #include "glut.h" //The main drawer for the game, draws everything to the screen. class GameDrawer { Level* m_currentLevel; //the current level to draw //drawing functions void drawFloor(); void drawCeiling(); public: GameDrawer(); ~GameDrawer(); void setLevel(Level* level); //sets the current level to draw void draw(); //draws the current level/menu to the screen }; #endif
I can edit this post with more information as needed. I really don't know what could be causing this. Any help would be appreciated.Code:Game::Game() { m_currentLevelNum = 0; m_currentLevel = 0; createLevel(64,64); } void Game::createLevel(short w, short h) { if (m_currentLevel) destroyLevel(); m_currentLevel = new Level(w,h); m_drawer->setLevel(m_currentLevel); } void Game::destroyLevel() { delete m_currentLevel; m_currentLevel = 0; }



LinkBack URL
About LinkBacks


