Correct way to define C++ namespace methods in .cpp file

后端 未结 8 1447
你的背包
你的背包 2020-12-12 11:10

Probably a duplicate, but not an easy one to search for...

Given a header like:

namespace ns1
{
 class MyClass
 {
  void method();
 };
}
8条回答
  •  天涯浪人
    2020-12-12 12:01

    Version 3 makes the association between the class and the namespace very explicit at the expense of more typing. Version 1 avoids this but captures the association with a block. Version 2 tends to hide this so I'd avoid that one.

提交回复
热议问题