We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
//头文件 named_namespace.h #ifndef NAME_17_2_3 #define NAME_17_2_3 namespace name_17_2_3 { class AA { AA() {} }; extern int name_17_2_3_fun(); //声明 extern int i; //声明 } #endif //实现文件 named_namespace.cpp #include "named_namespace.h" namespace name_17_2_3 { int name_17_2_3_fun() //定义 { return 998; } int i; //定义 }
#include <iostream> #include "named_namespace.h" //将命名空间name_17_2_3插入到当前位置,也就是全局作用域,相当于在此处定义命名空间; using namespace std; using namespace name_17_2_3; //using指示,处于全局作用域,; int i = 200; //全局变量; int main() { //using namespace name_17_2_3; cout << "i=" << i << endl; //调用哪一个 i 呢?编译器不知道应该使用哪个变量 i; return 0; }
name_17_2_3
No branches or pull requests
The text was updated successfully, but these errors were encountered: