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.

13th May 2017, 10:29 AM
Feraru Silviu Marian
Feraru Silviu Marian - avatar
1 Odpowiedź
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.
13th May 2017, 12:43 PM
Szabó Gábor
Szabó Gábor - avatar