C++ namespaces advice

前端 未结 9 1201
长发绾君心
长发绾君心 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:24

    You can skip indentation. I often write

    namespace myLib { namespace details {
    
    /* source code */
    
    } } /* myLib::details */
    

    C++ source code is eventually compiled into binary, unlike C#/Java which stays in the binary. Therefore, namespace just provides a fine solution for variable naming conflict. It is not intended for class hierarchy.

    I often keep one or two namespace levels in the code.

提交回复
热议问题