Shadowing Variables
•
If I use “x” at different points in the
program I could be getting different
variables.
•
int x = 0;
•
// here x = 0
•
{
•
int x = 1;
•
// here x = 1
•
}
•
// here x = 0
•
This code is fine because the variable y exists until the matching brace, which is at the end of the program after the cout << y << endl;