+ 1

I really got stuck on operator overloading concept. Can anyone provide me a detail concept on this topic?

8th Sep 2016, 6:45 PM
Munindra
Munindra - avatar
5 odpowiedzi
+ 3
Operator overloading is to be able to use operators like +, -, *, etc. with your custom classes, which means that instead of having to write something like obj3 = obj1.plus(obj2), you will be able to directly do obj3 = obj1 + obj2. The full list of operators that you can overload: + - * / % ˆ & | ~ ! = < > += -= *= /= %= ˆ= &= |= << >> >>= <<= == != <= >= && || ++ -- , ->* -> ( ) [ ]
8th Sep 2016, 6:59 PM
Zen
Zen - avatar
+ 3
what about < or > operators?
8th Sep 2016, 7:00 PM
Munindra
Munindra - avatar
+ 1
They are in the list, right between = and +=.
8th Sep 2016, 7:13 PM
Zen
Zen - avatar
+ 1
Here is an example of operator overloading with complex numbers: http://code.sololearn.com/c1U1xctsxowr
8th Sep 2016, 7:20 PM
Zen
Zen - avatar
0
thanks zen
24th Oct 2016, 8:31 PM
rosal
rosal - avatar