Namespace and class with the same name?

前端 未结 9 1510
终归单人心
终归单人心 2020-11-29 03:38

I\'m organizing a library project and I have a central manager class named Scenegraph and a whole bunch of other classes that live in the Scenegraph namespace.<

9条回答
  •  有刺的猬
    2020-11-29 04:28

    Giving the same name to the namespace and the class can confuse the compiler as others have said.

    How to name it then?

    If the namespace has multiple classes then find a name that defines all those classes.

    If the namespace has just one class (and hence the temptation to give it the same name) name the namespace ClassNameNS. This is how Microsoft names their namespaces at least.

提交回复
热议问题