Why we use operator overloading? Explain some cases where we can use operator overloading.
Operator overloading makes the code cleaner and simpler architecture.
If Operator overloading is not available then we have to write methods in the class to perform the same logic and have to call the method by name.
Adding or subtracting two complex numbers/ imaginary numbers
(a + i b) - we can overload
- operator to perform add and subtract operations respectively on complex number
Adding or subtracting rational numbers - we can overload + and - operator to perform add and subtract operations on rational number
(a/b + c/d)
We can overload both unary and binary operators.