But*_*ink 2 c++ namespaces using
我知道之前已经提出过一个非常相似的问题,"在c ++头文件中使用命名空间",但我的内部是命名空间.
namespace foo {
using namespace std; // what does this do?
class Bar { ... }
}
Run Code Online (Sandbox Code Playgroud)
这是否与其他问题完全相同,只是在所有地方使用声明?它只在该命名空间中执行吗?它只在标题中执行吗?
有两点不同:
using只会应用于foo命名空间内的代码.但这意味着所有foo看到此标题的代码,所以您可能仍然不想这样做.foo::std存在,嵌套using语句将优先于它::std.