I am currently programming an int matrix in cpp.
I wanted to add a printing function that prints the numbers in the following way:
1 2 3
7 6 9
19 23 9
(every 2 intergers are seperated with a space, in the end of the line no space). so I wrote the following code:
std::ostream& IntMatrix::operator << (std::ostream& out) const
{
for(int i = 0; i < this->num_row; i++)
{
int j;
for(j = 0; j < this->num_col - 1; j++)
{
out << this->mat[i][j] << " ";
}
out << this->mat[i][j] << endl;
}
return out;
}
which is in the file IntMatrix.cpp. however, every time I try to compile the code, this is what happens:
error: cannot bind 'std::ostream {aka std::basic_ostream<char>}' lvalue to 'std::basic_ostream<char>&&'
What to do?