Yes, so you can see that it also applies when overloading binary operators: the current object (i.e., *this) is the left hand operand when overloading as a member function.
Printable View
Yes, so you can see that it also applies when overloading binary operators: the current object (i.e., *this) is the left hand operand when overloading as a member function.
It would be legal as a non-member if the left-hand (the first) parameter was a reference to dummy_class. That is,
void operator+(dummy_class& lhs, dummy_class* test); // Fine
void operator+(dummy_class* lhs, dummy_class* test); // Not fine
Also note that operator + should return a temporary of its left-hand side type. So it should be
dummy_class operator+(dummy_class& lhs, dummy_class* test);
No, it's because it's a built-in operator. And you may not overload those.
But addition of two pointers is not an operation which is defined?
True, pointer addition is not defined. Yet, it's still not allowed.
Dumb of me to call it a built-in operator.
Great, so I was correct it #18. Thanks for pointing it out.