【发布时间】:2016-05-29 16:37:48
【问题描述】:
我有一个班级垫
template <class A_Type,int sizeA,int sizeB>
class Matrix {
..
..
..
Matrix operator*(int elem){
Matrix res = *this;
res.multiWith(elem);
return res;
}
};
现在我需要它同时使用 Mat*2 和 2*Mat
而且我有语法错误...
在网上找不到任何示例...知道如何编写吗?
【问题讨论】:
-
Mat与Matrix<A_Type,sizeA,sizeB>实际上有什么关系? -
“我有语法错误...” 请始终在您的问题中逐字提供编译器错误。此外,您应该始终提供代码的minimal reproducible example,以重现问题。
标签: c++ class templates operator-overloading