C++ 错误:与‘;不匹配;操作员<’;当我流到库特的时候
我正在创建一个矩阵类,我正在重载所有的基本运算符。例如:C++ 错误:与‘;不匹配;操作员<’;当我流到库特的时候,c++,C++,我正在创建一个矩阵类,我正在重载所有的基本运算符。例如: class Matrix { Matrix operator<(const float& ); // returns a Matrix with // entries 0 or 1 based on // whether the element is less than
class Matrix {
Matrix operator<(const float& ); // returns a Matrix with
// entries 0 or 1 based on
// whether the element is less than
// what's passed in.
};
类矩阵{
矩阵运算符左流运算符像cout或等效地调用它,运算符谁愚蠢的决定是让左移位运算符成为写入流的一种方式?我真的很喜欢运算符cout
ostream &operator<<(ostream&cout,const Matrix &M){
for(int i=0;i<M.rows;++i) {
for(int j=0;j<M.columns;++j) {
cout<<M.array[i][j]<<" ";
}
cout<<endl;
}
return cout;
}
int main() {
Matrix M1;
cout << M1 < 5.8;
}