int a = 4;
if(a < 10)
{
int b = 4;
a = 100;
}
// a == 100 here
// b is dead
Thanks, I think there is something else stopping it working then.To do with scope of where the variable is first declared. If it's declared outside the IF statement then it will keep its value, e.g
Code:int a = 4; if(a < 10) { int b = 4; a = 100; } // a == 100 here // b is dead
If you declare a variable inside the if, then it is killed when the scope changes.
^^ thisTo do with scope of where the variable is first declared. If it's declared outside the IF statement then it will keep its value, e.g
Code:int a = 4; if(a < 10) { int b = 4; a = 100; } // a == 100 here // b is dead
If you declare a variable inside the if, then it is killed when the scope changes.
Finally got my program finished, been working on it solidly 10 hours today.
Get it here if you want to take a look. Hangman isn't very interesting but still a challenge since I only started programming last September.
I uploaded the code too so any tips would be appreciated. I have a tic tac toe one to make too.
You're going to have to explain that to me.My main comment would be remember that C++ is object orientated, you're not benefiting from that at all with your program.
You're going to have to explain that to me.