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

后端 未结 8 1441
你的背包
你的背包 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 11:51

    5 years later and i thought I'd mention this, which both looks nice and is not evil

    using ns1::MyClass;
    
    void MyClass::method()
    {
      // ...
    }
    

提交回复
热议问题