简单的块范围
块 { ... } 中变量的范围在声明之后开始,并在块的结尾处结束。如果存在嵌套块,则内部块可以隐藏在外部块中声明的变量的范围。
{
    int x = 100;
    //   ^
    //   Scope of `x` begins here
    //
}   // <- Scope of `x` ends here
如果嵌套块在外部块中开始,则在外部类中具有相同名称的新声明变量将隐藏第一个。
{
    int x = 100;
    {
        int x = 200;
        std::cout << x;  // <- Output is 200
    }
    std::cout << x;  // <- Output is 100
}