This partial code is for a matrix calculator and I'm trying to overload the operator << so that it will be written to another file. I'm getting this error
"qualifiers dropped in binding reference of type "Matrix &" to initializer of type "const Matrix"."
ostream& operator<< (ostream& os, const Matrix& a)
//overload the stream insertion operator <<
{
int rows, columns;
os << rows << columns;
if (!os) return os;
Matrix temp(rows,columns);
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
os << temp.matrix[i][j];
if (!os) return os;
}
}
temp.swap(a);//what does swap do?? <<<-----I'm getting an error here
return os;
}
istream& operator>> (istream& is, Matrix& a)
//overload the stream extraction operator >>
{
int rows, columns;
is >>rows>>columns;
if (!is) return is;
Matrix temp(rows,columns);
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < columns; ++j) {
is >> temp.matrix[i][j];
if (!is) return is;
}
}
temp.swap(a);
return is;
}
Any suggestions please let me know. Thanks I appreciate it!