no match for overloaded operator
The line code that has the error
Code:
Matrix4d M = T*R4*R1.inverse();
The error
Code:
/Users/usi/Desktop/RayTracerFrameWork/CCanvas.cpp:45: error: no match for 'operator*' in 'T. Matrix4d::operator*(((Matrix4d&)(& R4))) * R1. Matrix4d::inverse()'
/Users/usi/Desktop/RayTracerFrameWork/Matrix4.h:204: candidates are: const Matrix4d Matrix4d::operator*(Matrix4d&) const
The function
Code:
/**
* Multiplication of two matrices.
* @param m - the other Matrix
* @return the <b> product </b> of the matrix multiplication
*/
const Matrix4d operator * ( Matrix4d& m ) const {
Matrix4d M;
// set matrix diagonals to 0
for (int r=0; r<4; r++) { M(r,r) = 0; M(r,r,-1) = 0;}
// Now multiply the two matrices:
for (int r=0; r<4; r++)
for (int c=0; c<4; c++)
for (int i=0; i<4; i++) {
M(r,c) += _v[r][i]*m(i,c);
M(r,c,-1) += m(r,i,-1)*_inv[i][c];
}
return M;
};
the inverse function
Code:
/*
* returns the invers of the current matrix:
*/
Matrix4d inverse()
{
Matrix4d M;
for (int r=0; r<4; r++)
for (int c=0; c<4; c++) {
M(r,c) = _inv[r][c];
M(r,c,-1) = _v[r][c];
}
return M;
};
The fields of the class Matrix4d
Code:
double _v[4][4];
double _inv[4][4];
If i change the prototype of the function to this
Code:
const Matrix4d operator * ( Matrix4d m ) const
(without the &) then it will work ok.Can i do it by using the &operator for the parameter ?
Like this
Code:
const Matrix4d operator * ( Matrix4d m ) const
edit : Or to be more exact what should i write in line that produces the error?