I would like to override all = operators where the lhs is a known type the the rhs is my own class. As an example:
class MyClass;
class Override {
long operator+=(long X, const MyClass& Y);
}
long Override::operator+=(long X, const MyClass& Y) {
return X += (long)Y;
}
void main(int argc, char** argv) {
MyClass X(1);
long Y = 1;
Y += 1; // works great
Y += (long)X; // works great
Y += X; // does not work
}
And MyClass has the appropriate casting and creation methods.
I know I'm missing something but I can't figure out what.
I get a compiler error on
Y += X
with the following function
long Override::operator(long& X, const MyClass& Y) ...
Can anyone tell me what the correct way of doing this is?
thanks art