Scope of Variables, Example
•
int main
•
{
•
int y = 0;
•
{
•
int x = 0;
•
}
•
cout << y << endl;
•
return 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;