在using namespace匿名命名空间内使用语句时,将使用的命名空间带入文件范围?例如:
namespace foo
{
int f() { return 1; }
}
namespace
{
using namespace foo;
}
int a()
{
return f(); // Will this compile?
}
Run Code Online (Sandbox Code Playgroud) 我想知道放在哪里using namespace std;.我看到的代码using namespace std;中int main(){} ,但我以后把它#include <iostream>.我应该把它放在哪里,它在我放的地方有什么不同吗?
很抱歉这个愚蠢的问题,但有没有办法将using指令限制在当前文件中,以便它们不会传播到#include这个文件的文件?