int main(){
int a=3;
cout << "----input-------" << endl;
cout << "a=" << a << endl;
{
int a = 4;
cout << "a=" << a << endl;
}
cout << "a=" << a << endl;
int a=3;
cout << "----input-------" << endl;
cout << "a=" << a << endl;
{
int a = 4;
cout << "a=" << a << endl;
}
cout << "a=" << a << endl;
}
输出
----input-------
a=3
a=4
a=3
可见,在花括号中定义的变量,在出了 花括号后就 不起作用了。