In C++ we can specify more than one definition for a function name or an operator in the same scope. This is called function overloading and operator overloading respectively.
When you call an overloaded function or operator, the compiler determines the most appropriate definition to use. It is also done by comparing the argument types you have used to call the function or operator with the parameter types specified in the definitions.
Important points about operator overloading
1) For operator overloading to work, at least one of the operands must be a user defined class object.
2) Assignment Operator: The default assignment operator does assign all members of right side to the left side and works fine in most of the cases (this behavior is same as copy constructor). As a result, the compiler automatically creates a default assignment operator with every class.
3) Conversion Operator: We can also write conversion operators that can be used to convert one type to another type.
4) Any constructor that can be called with a single argument works as a conversion constructor, means it can also be used for implicit conversion to the class being constructed.
For example, we can overload an operator ‘+’ in a class like String to concatenate two strings.
18 + i8