Do you prefer explicit namespaces or 'using' in C++?

前端 未结 8 903
旧巷少年郎
旧巷少年郎 2020-12-06 01:16

When using C++ namespaces, do you prefer to explicitly name them, like this:

std::cout << \"Hello, world!\\n\";

Or do you prefer

8条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-06 01:28

    I always use using namespace for std & boost. Everything else I tend to use an explicit namespace unless it is used so much that it would clutter up the code.

    In headers, I never use using namespace to avoid polluting the global namespace of the #including source.

提交回复
热议问题