
matrix multiplying
I have seen all the other threads but I can't get mine to work. I am trying to multiply two matrices with overloading operators.
mat[SIZE][SIZE] is my private variable
SIZE is initalized to 2 for now
Code:
Matrix & Matrix::operator *= ( const Matrix & rhs )
{
Matrix temp;
for(int i = 0; r < SIZE; ++i)
{
for(int j = 0; j < SIZE; ++j)
{
for(int k = 0; k < SIZE; ++k)
{
mat[i][j] += mat[i][k] * rhs.mat[k][j];
}
}
}
return * this;
}
Matrix Matrix::operator * ( const Matrix & rhs ) const
{
Matrix ret_val (* this);
ret_val *= rhs;
return ret_val;
}

I believe you had it right the first time. I'm pretty sure you need a temporary to do the multiplication. But then once temp holds the result, you must then copy temp to mat before returning *this.
