我想在C++中执行操作符重载; 由于某些原因,编译不断给我的错误运算符重载C++
error: ‘bool Matrix::operator==(const Matrix&, const Matrix&)’ must take exactly one argument
现在,我知道有一些方法来给它用这一个说法,但我明白,用的朋友,我可以这样来做,但它仍然无法正常工作。
这是我的代码,
在此先感谢。
class Matrix{
public:
Matrix();
friend bool operator==(Matrix &mtrx1,Matrix &mtrx2);
friend bool operator!=(Matrix &mtrx1,Matrix &mtrx2);
protected:
std::vector<Cell> _matrix;
int _row;
int _col;
};
inline bool Matrix::operator==(const Matrix& mtrx1, const Matrix& mtrx2){
/* .......... */
}
很好地格式化代码,用4个空格缩进它,或者选择它并按下0和1的按钮。 – 2010-09-20 23:17:03