deleting and re-assigning a global variable pointer
I have a global variable
Game * game;
in main I have game = new Game();
and I have another function which monitors the progress of the game and if the current level is completed then I want to do game = new Game() again to start a new game but I want to clean up the heap so I do the following:
but it won't compile. I'm using VC++ and I get the following compiler error:
void Timer(int extra)
if (game->level < 50)
game = new game();
cout << "you beat the game congrats" << endl;
error C2061: syntax error : identifier 'game'
Is this because I'm using a global variable?
I did something similar to pointers to characters instead of game but the pointer was a member and not global. Can Game * game not be a global variable if I want to delete it and reassign it as I showed above?