Why shouldn't I put “using namespace std” in a header?

前端 未结 2 1363
孤城傲影
孤城傲影 2020-12-12 04:31

Someone once hinted that doing this in a header file is not advised:

using namespace std;

Why is it not advised?

Could it cause lin

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 05:09

    Because it forces anyone who uses your header file to bring the std namespace into global scope. This could be a problem if they have a class that has the same name as one of the standard library classes.

提交回复
热议问题