<分区>
我正在尝试下面的代码,在一个函数中使用多个命名空间(更改命名空间)。我不确定哪里出了问题,我什至不确定我是否可以像下面这样使用,但在我短暂的浏览中没有找到任何矛盾的证据,请告诉我哪里出了问题:
#include <iostream>
using namespace std;
namespace standard_one
{
int i = 10;
}
namespace standard_two
{
int i = 40;
}
main()
{
using namespace standard_one;
cout << "value of i is " << i << endl;
{
using namespace standard_two;
cout << "value of i after namespace change is " << i << endl; // Compilation error here, compiler is complaining that "i" is undeclared
}
}