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

后端 未结 8 1455
你的背包
你的背包 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:06

    It turns out it's not only "coding-style matter". Num. 2 leads to linking error when defining and initializing a variable declared extern in header file. Take a look at example in my question. Definition of constant within namespace in cpp file

提交回复
热议问题