namespaces, classes and free functions - when do you need fully qualified names

前端 未结 4 1855
醉梦人生
醉梦人生 2021-02-03 13:30

In my example below, why do I have to fully qualify the name of the free function in the cpp to avoid linker errors and why does it work for the class function without? Can you

4条回答
  •  醉酒成梦
    2021-02-03 14:04

    When implementing a function it is usually preferable, I find, to open the namespace. Remember you can re-open them...

    // in Test.cpp
    namespace Test
    {
       int FreeFunction()
       {
           return 0;
       }
    }
    

提交回复
热议问题