What requires me to declare “using namespace std;”?

后端 未结 12 2175
抹茶落季
抹茶落季 2020-12-17 10:55

This question may be a duplicate, but I can\'t find a good answer. Short and simple, what requires me to declare

using namespace std;

in C+

12条回答
  •  一向
    一向 (楼主)
    2020-12-17 11:33

    You should definitely not say:

    using namespace std;
    

    in your C++ headers, because that beats the whole point of using namespaces (doing that would constitute "namespace pollution"). Some useful resources on this topic are the following:

    1) stackoverflow thread on Standard convention for using “std”

    2) an article by Herb Sutter on Migrating to Namespaces

    3) FAQ 27.5 from Marshall Cline's C++ Faq lite.

提交回复
热议问题