访问全局和命名空间变量

问题描述

我正在尝试使用以下代码中的 using 指令访问变量 x:

#include <iostream>
using namespace std;
int x = 10;
namespace e {
int x = 5;
}
int main() {
using namespace e; // Because of this line compiler shows error
cout << x;
return 0;
}

通常我们使用以下行访问 x 但我收到错误 我们也可以使用 using e::x; 但我的问题是为什么我们不能使用 using namespace e;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)