Can someone explain the basics of operator-overloading for me? | SoloLearn: Learn to code for FREE!

+1

Can someone explain the basics of operator-overloading for me?

I am making a program that would be nice with it. Can someone give me an example and explain how it works? It would be so helpful, thank you ^^

3/13/2017 3:13:16 AM

Rain

2 Answers

New Answer

+3

Operator Overloading -------------------------------------------------------------------------------------------- - This helps in redefining operator with respect to the object - Almost all operators can overloaded except - ., ::, :, ?, -> <return-type> operator <sym> (parameter); For example please visit https://code.sololearn.com/cKpSHlLsr1Ih/#cpp

0

operator overloading is done to use one operator in a sense for which it was defined. eg. void operator + (obj a, obj b) { obj c; c.q=a.q+b.q; printf("addition of two objects : %d",c q); } here + was originally defined for adding two numerals, but here is redefined to add two objects.