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.
This is a discussion on Overloading unary operators using pointers within the C++ Programming forums, part of the General Programming Boards category; Yes, so you can see that it also applies when overloading binary operators: the current object (i.e., *this) is the ...
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.
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
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);
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
No, it's because it's a built-in operator. And you may not overload those.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
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.
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Great, so I was correct it #18. Thanks for pointing it out.