Hello, I have another question
I have this hierarchy:
Matrix
MatrixMxN
Matrix6x6
Vector
Vector4D
Vector2D
I can define operators like + and - on MatrixNxM but if both the
operands are Matrix6x6 (or Vector etc), for instance, I would like a
Matrix6x6 returned (6 by 6 matrices are special to me).
How could I do this?
I tried overloading the operators like this:
public static Matrix6x6 operator - (Matrix6x6 m1, Matrix6x6 m2)
{
Matrix6x6 result = new Matrix6x6();
result.data = (((MatrixMxN)m1) - ((MatrixMxN)m2)).Data;
return result;
}
and then define a cast for MatrixMxN to Matrix6x6, but the compiler
said I couldn't do that for derived types. Seemed like a bit of a
mess anyway.
I don't want to have to define all these operators for all the
classes. They're essentially the same function, just a different
class to hold the result.
Does anyone know what I'm on about?
Thanks,
Bob