0
Help me understand the syntax
I don't understand the syntax's logic. In MyClass operator+, I assume we are overloading the operator "+" only for objects of the type "MyClass", simple enough. So this operator takes in a parameter, &obj, an object of the type MyClass, it's not clear for me what exactly it takes in as the parameter, obj1 or obj2 ? How do we know which is the current object, and which is the parameter object.
1 Respuesta
0
If it has one parameter that is the other object, the current object reachible by the this pointer. In this case its defined as a class operator.
If has 2 params left has side LHS and RHS. Its defined outside of class, and works same.