Implementing a non template method defined in a template class

前端 未结 5 888
盖世英雄少女心
盖世英雄少女心 2021-01-04 08:14

When I want to define a method declared in a template class, but that the method doesn\'t depend on the template parameters, have I to define it in the include files as :

5条回答
  •  情书的邮戳
    2021-01-04 09:00

    You have to define it in an even other way. The method itself may not (directly) depend on the template parameter, but the class to which it belongs certaily does, no? As such, the method indirectly depends on the template parameter too:

    template class
    void MyClass::myMethod()
    {  //       ^^^ -- note
       ...
    }
    

提交回复
热议问题