+ 1
I really got stuck on operator overloading concept. Can anyone provide me a detail concept on this topic?
5 Réponses
+ 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: + - * / % ˆ & | ~ ! = < > += -= *= /= %= ˆ= &= |= << >> >>= <<= == != <= >= && || ++ -- , ->* -> ( ) [ ]
+ 3
what about < or > operators?
+ 1
They are in the list, right between = and +=.
+ 1
Here is an example of operator overloading with complex numbers:
http://code.sololearn.com/c1U1xctsxowr
0
thanks zen