I haven't properly extrapolated about operator overloading guys! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I haven't properly extrapolated about operator overloading guys!

There is this lesson that's too had to deduce. What is the purpose of the default constructor while overloading? In fact, how does the whole process work? https://code.sololearn.com/ca8ZGaXwVv4s/?ref=app

20th Nov 2019, 4:04 PM
Hilary
Hilary - avatar
2 Answers
+ 2
John Wells thanks. That's giving me clue No1.
21st Nov 2019, 6:31 AM
Hilary
Hilary - avatar
+ 1
The default constructor has no purpose in relation to operator overloaded. Your code could be modified so there is no default, instead of using it twice. MyClass res = obj1+obj2; is identical to this: MyClass res = obj1.operator+(obj2);
21st Nov 2019, 2:25 AM
John Wells
John Wells - avatar