Matrix4 Matrix4::operator*(Matrix4& m) {
Matrix4 r;
int index = 0;
for(int col = 0; col < 4; col++) {
for(int row = 0; row < 4; row++) {
float sum = 0.0f;
for(int i = 0; i < 4; i++) {
sum += m.raw()[i + col * 4]*mat[row + i * 4];
}
r.raw()[index] = sum;
index++;
}
}
return r;
}
Matrix4& Matrix4::operator=(Matrix4& m) {
for(int i = 0; i < 16; i++) {
mat[i] = m.raw()[i];
}
return *this;
}
And I'm trying to translate an existing matrix every frame, by doing
1 2
Matrix4 t = Matrix4::translation(elapsed * speed + lastPos, 0.0, 0.0);
matrix = matrix * t; //ERROR HERE
But I'm getting a compiler error saying 'No viable overloaded '=''. Why would it say that when I clearly have overloaded the operator, and the types are correct?