Operator overloading | Sololearn: Learn to code for FREE!


Operator overloading

What is the main purpose of operator overloading in c++ or any other programming language? Any examples that can only be done using overloaded operator

12/2/2019 9:46:37 AM


6 Answers

New Answer


Operator overloading is not needed, but make things clearer. Instead of many function calls with your class variables: d.plus(e).times(f), you can code: (d+e)*f. Here is a simple example of using it. It includes links to similar code in other languages. https://code.sololearn.com/cStdw0OPtPxG


One example of operator overloading is for doing some maths operations like +,×,÷,/etc b/w user defined datatypes like class struct.


Thank you everybody you help me so much, now i understand it, keep up a good work!! Thanks


In "More On Classes" chapter https://www.sololearn.com/learn/CPlusPlus/1901/



How we can know the problem solve in function