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

蓝咒 提交于 2019-11-28 14:32:24

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.

If the file gets included elsewhere the compilation unit will implicitely get the using directive. This can lead to confusing errors when names overlap.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!