Why and how should I use namespaces in C++?

后端 未结 6 1684
甜味超标
甜味超标 2020-12-02 18:59

I have never used namespaces for my code before. (Other than for using STL functions)

  1. Other than for avoiding name conflicts, is there any other reason to use
6条回答
  •  被撕碎了的回忆
    2020-12-02 19:06

    Here is a good reason (apart from the obvious stated by you).

    Since namespace can be discontiguous and spread across translation units, they can also be used to separate interface from implementation details.

    Definitions of names in a namespace can be provided either in the same namespace or in any of the enclosing namespaces (with fully qualified names).

提交回复
热议问题