operator overloading


I really need to understand the concept of it .please help me with it .\
I just understand why we pass an object when we overload a operator .
Last edited on
Let's say we have two strings:
1
2
string hello = "Hello";
string world = " World";


Let's append world to hello. We could do it in two ways:
hello.append(world);
or
hello += world;

The first one can get verbose. Therefore sometimes when we use an operation a lot, we like to assign a logical operator as a shortcut.

A good example would be operator overloads with complex numbers, check these out.
http://www.cplusplus.com/reference/complex/complex/operators/
Last edited on
Topic archived. No new replies allowed.