Hey all, I'm working on a simple 3d engine (probably just a starfield simulation) but am running accross problems in my operator* code (this is for 4x4 matrices):
Code:
M4x4 M4x4::operator*(const M4x4 &mat)
{
M4x4 product;
for(int i = 0; i < 4; i++)
for(int j =0; j < 4; j++)
product.setValue(i,j, (float)(this->matrix[i][1] * mat.getValue(1,j)
+ this->matrix[i][2] * mat.getValue(2,j)
+ this->matrix[i][3] * mat.getValue(3,j)));
return product;
}
where setValue set's matrix[i][j] to a float value and getValue returns the float, matrix[i][j].
I'm getting the following errors in Metrowerks Codewarrior IDE 4.1:
Code:
Error : cannot pass const/volatile data object to non-const/volatile member function
M4x4.cpp line 26 product.setValue(i,j, (float)(this->matrix[i][1] * mat.getValue(1,j)
Error : cannot pass const/volatile data object to non-const/volatile member function
M4x4.cpp line 27 + this->matrix[i][2] * mat.getValue(2,j)
Error : cannot pass const/volatile data object to non-const/volatile member function
M4x4.cpp line 28 + this->matrix[i][3] * mat.getValue(3,j)));
Error : cannot pass const/volatile data object to non-const/volatile member function
M4x4.cpp line 38 sum.setValue(i,j, matrix[i][j] + mat.getValue(i,j));
Which doesn't make a whole lot of sense to me.
is there something wrong with this code? Maybe it's something elsewhere in my code causing this particular section to mess up?
Help please.