(请教)关于模板与vector与运算符重载
小弟试图通过vector类来定义一矩阵,定义过程如下:template <typename T>
class Matrix{
typedef Matrix<T> MYT;
public:
Matrix(){};
Matrix(int r1,int j1);
T& operator ()(int row,int line);
const T operator ()(int row,int line) const;
int get_row(const MYT&);
int get_line(const MYT&);
MYT operator +(MYT& temp1,MYT& temp2);
private:
int nr,nc;
vector<vector<T> > mat;
};
经过编译,结果提示错误如下:
14 D:\Program Files\DEV-CPP\WORK\matrix\matrix3.h `Matrix<T> Matrix<T>::operator+(Matrix<T>&, Matrix<T>&)' must take either zero or one argument
17 D:\Program Files\DEV-CPP\WORK\matrix\matrix3.h ISO C++ forbids declaration of `vector' with no type
改了很多次,都没有搞清楚问题在哪,希望达人帮帮忙