Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以有一段时间我一直在使用...
using namespace::std;
最近我意识到这应该是
using namespace std;
有人可以向我解释为什么我正在做的工作,以及它与声明使用某个命名空间的正确方式有何不同?
第一个版本有效,因为编译器将其视为
using namespace ::std; // Notice space^
这只是告诉编译器std在全局范围内查找名称空间。
std
::左侧没有任何内容的范围运算符与全局范围相同。
::