C++ - how to implement templated member function outside a templated class

后端 未结 2 1672
一生所求
一生所求 2021-02-07 18:55
template
class myClass
{
    template
    void myFunction();
};

template
void myClass::myFunction() {} //          


        
相关标签:
2条回答
  • 2021-02-07 19:07

    You are looking for:

    template <int N>
    template <typename T> 
    void myClass<N>::myFunction() {} 
    

    You need one template for the class template and one for the member function template.

    0 讨论(0)
  • 2021-02-07 19:14
    template<int N> template<typename T>
    void myClass<N>::myFunction() {}
    
    0 讨论(0)
提交回复
热议问题