1.::作用域运算符
::双冒号为全局运算符
#include <iostream> using namespace std; int atk = 200; void Test() { int atk = 100; cout << "Test内部:" << atk << endl; cout << "Test外部:" << ::atk << endl; } int main() { Test(); system("Pause"); return EXIT_SUCCESS; }
结果
2023-02-25 19:24:34
1.::作用域运算符
::双冒号为全局运算符
#include <iostream> using namespace std; int atk = 200; void Test() { int atk = 100; cout << "Test内部:" << atk << endl; cout << "Test外部:" << ::atk << endl; } int main() { Test(); system("Pause"); return EXIT_SUCCESS; }
结果