变量作用域


#include <iostream>
 
int main()
{
    int number = 0;
    {
        int number = 10;
        std::cout<<number<<std::endl;
    }
    std::cout<<number<<std::endl;
}
class MainApp
{
    static void Main()
    {
        int number = 0;
        {
            // Error:
            // A local or parameter named 'number' cannot be declared in this scope because
            // that name is used in an enclosing local scope to define a local or parameter
            int number = 10;
        }
    }
}