Hey R0mai, thanks for that awesome reply!
Went through and fixed all that stuff you pointed out lol I'm not sure why I was returning the result by reference, I'm still working my way through this pointer stuff lol
tVal was the problem, the compiler just wasn't pointing me there lol
Everything works now, but I tried to overload:
Matrix operator*(float, const Matrix&); |
and failed. Do I define this in my Matrix class of somewhere else? Here was my attempt and the error that followed lol:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
class Matrix{
public:
float **pMatrix;
int nRows, nCols;
Matrix(int rows, int columns);
Matrix();
void setValue(int row, int col, float value);
void outputMatrix() const;
Matrix operator * (Matrix m) const;
Matrix operator * (float m) const;
Matrix operator * (float m, Matrix mat) const;
Matrix operator + (Matrix m) const;
Matrix operator / (float m) const;
Matrix operator / (float, Matrix) const;
};
|
Error: Matrix Matrix::operator*(float, Matrix)' must take either zero or one argument
I did go and read the tutorial on overloading before I posted here. I think this is what I should be looking at:
a*b A::operator* (B) operator*(A,B) |
Which would mean in this case i.e. float*Matrix, I'd need to go:
1 2 3
|
float::operator* (Matrix)
|
Am I even close to figuring this out? lol
Anyway, your help is awesome!
Nick