C++:双冒号(::)作用域运算符
#include <iostream>
using namespace std;
int a = 1000;
void test01(void)
{
int a = 2000;
cout<<"(局部变量)a = "<<a<<endl;
// 作用域::变量名
// 若跟作用域名,则此时变量应为该作用域下的变量。
std::cout<<"(全局变量)a = "<<::a<<std::endl;
// 若::前什么也不跟,则代表全局作用域。
cout<<"(全局变量)a = "<<::a<<endl;
}
int main()
{
test01();
return 0;
}