So, I have a generic Matrix class that I created that has the following operational overload:
class Matrix { public: Matrix() {} Matrix(int i, int j, int k) {} Matrix operator*(const Matrix &right) { } };
I also have a Matrix2 class that inherits from my Matrix class.
class Matrix2 : public Matrix { };
When I try to multiply two Matrix2 objects, I get a compiler error message:
'no operator was found that accepts a left operand of type Matrix2 (or there is no conversion available)'
Why is this and how can I correctly implement operator overloads with inheritance?
EDIT:
As stated, my problem was partly due to "the most unpleasant parsing." Now my problem, I believe, is strictly related to operator overloading and inheritance.
I can multiply two Matrix objects just fine, but I cannot combine two Matrix2 objects multiple times.
Matrix2 i; Matrix2 m; Matrix result = m * i;
Error message:
error C2678: binary '*' : no operator found which takes a left-hand operand of type 'Matrix2' (or there is no acceptable conversion).
source share