#include<iostream>
using namespace std;
int main( )
{
{
int x=1;
cout<<x<<" The first output!"<<endl; //输出1
{
int x=2;
cout<<x<<" The second output!"<<endl; //输出2
{
int x=3;
cout<<x<<" The third output!"<<endl; //输出3
}
cout<<x<<" The fourth output!"<<endl; //输出2
}
cout<<x<<" The fifth output!"<<endl; //输出1
}
return 0;
}
注意语句块和作用域。
如果把最中间的那一对大括号去掉,则出现重定义编译错误,由此可见大括号在这里起的作用!