+ 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 ^^

13th Mar 2017, 3:13 AM
Rain
Rain - avatar
2 Antworten
+ 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
13th Mar 2017, 1:43 PM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
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.
13th Mar 2017, 5:51 PM
kundan kumar
kundan kumar - avatar