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

后端 未结 6 1675
甜味超标
甜味超标 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:19

    It can help you for a better comprehension.

    eg:

    std::func <- all function/class from C++ standard library
    lib1::func <- all function/class from specific library
    module1::func <-- all function/class for a module of your system
    

    You can also think of it as module in your system.

    It can also be usefull for an writing documentation (eg: you can easily document namespace entity in doxygen)

提交回复
热议问题