...
gamestate *thisGame = new gamestate ;
initGame(thisGame) ;
...
void initGame(gamestate *thisGame){
thisGame->rowcount = 0 ;
thisGame->score = 0 ;
thisGame->gameCount = 0 ;
}
Help! Variable initializing won't stick!
For some reason, I can't seem to assign an values to a variable. In the debugger, it shows 'no runtime value'. Here's what I'm doing:
It executes each line of code, but seems to just throw away the values. After each line in initGame(), the value in the debugger still shows 'no runtime value'. What's the problem?
Hmm. If you're just hovering the mouse over the variables, it won't necessarily 'understand' it. To make sure if it's working, right click on the object (thisGame) and go to quickwatch - does it still say they're uninitialised?
Where in the program's flow are you checking the variable? The variable gameState will have a local scope of the function it's declared in - i.e. it won't be valid once that function returns.
Where in the program's flow are you checking the variable? The variable gameState will have a local scope of the function it's declared in - i.e. it won't be valid once that function returns.
I tried the quick watch and for each element of the structure it shows <no runtime value>. I'm checking it immediately after it executes the line of code that sets the variable. It will execute thisGame->rowcount = 0 and still show <no runtime value>.
This is even more strange. This produces the same result:
Am I missing a step to using a pointer to this object?
gamestate *thisGame = new gamestate ;thisGame->rowcount = 0 // still shows <no runtime value>
Am I missing a step to using a pointer to this object?
Try deleting all your object files and recompiling. Sometimes the debug line info goes wrong.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement