This is a discussion on overloading operator in C++ within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by -EquinoX- okay... some say that using operator cast will allow me to use one function definition Beware ...
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
I don't think the reason for this is technical at all. I think it's fairly easy: you can't assume that a*b == b*a. That is, not all multiplications are commutative. Sure, the multiplication of two integers is, but matrix multiplication is not, for instance. So let's say we have operator*(Matrix1Type, Matrix2Type) and the operator* of the two reversed is called, we get unexpected results, which are probably fairly hard to debug as well.
That is kind of what I meant by technical. The compiler cannot assume that the two will do the same thing.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^