我有一个看起来像这样的课程
template<class T>
class Matrix {
...
template<class T2> auto dot(Matrix<T2> const& other);
}
这是我的实现,在头文件中的声明下:
template<class T, class T2>
auto Matrix<T>::dot(Matrix<T2> const& other) {
[impl]
}
我得到的错误看起来像这样:
(C2244) 'Matrix<T>::dot' : unable to match function definition to an existing declaration
我要去哪里错了?
语法错误。您在具有template parameterT2
的类模板中具有具有template参数的功能模板T
。必须这样定义:
template<class T>
template<class T2>
auto Matrix<T>::dot(Matrix<T2> const& other) {
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句