当前位置: 动力学知识库 > 问答 > 编程问答 >

c++ - "using namespace" in header in namspace

问题描述:

I know that a question very similar has been asked before, "using namespace" in c++ headers, but mine is when its inside of a namespace.

namespace foo {

using namespace std; // what does this do?

class Bar { ... }

}

Does this do exactly the same thing as the other question says and just include that using statement everywhere? Does it only do it in that namespace? Does it only do it in that header?

网友答案:

There are two differences:

  1. Yes, the using will only apply to code inside the foo namespace. But that means all foo code that sees this header, so you probably still don't want to do it.
  2. If the namespace foo::std exists, the nested using statement will favor it over ::std.
分享给朋友:
您可能感兴趣的文章:
随机阅读: