#include <iostream>
using namespace std;
int a{ 1 };
int main() {
int a{ 123 };
cout << "外部的a:" << a << endl; //外部的a:123
{
cout << "外部的a:" << a << endl; //外部的a:123
int a{ 456 };
cout << "内部的a:" << a << endl; //内部的a:456
a = a + 1;
cout << "内部的a:" << a << endl; //内部的a:457
//使用限定符访问全局变量
cout << "全局的a:" << ::a << endl; //全局的a:1
}
cout << "外部的a:" << a << endl; //外部的a:123
cout << "全局的a:" << ::a << endl; //全局的a:1
}