C++ namespaces advice

前端 未结 9 1200
长发绾君心
长发绾君心 2020-11-28 21:48

I\'m just teaching myself C++ namespaces (coming from a C# background) and I\'m really starting to think that even with all the things that C++ does better than most other l

9条回答
  •  佛祖请我去吃肉
    2020-11-28 22:25

    First of all you can avoid namespace indentation, because there is no reason for that.

    Using namespaces in the examples won't show namespaces power. And their power as for me is dividing Domain areas one from another. Divide utility classes from the business ones.

    Just don't mix different namespace hierarchies in the one .h file. Namespaces are kind of extra comment for your interface of functions declaration. Looking on namespaces and the class names should explain a lot of stuff.

    namespace product
    {
    namespace DAO
    {
    
    class Entity
    {
    };
    

提交回复
热议问题