In this video session we will cover an important topic of C++. That is called operator overloading. In C++ we have already discussed function overloading. Overloading concept in C++ means that there are more than one function or functionality exist in program that have same name or symbol. As similar with function overloading, operator overloading also mean that single operator will behave differently depending on its operands.
In this lecture we will understand that how we can use the common C++ operators such as +,-,*,/ for our class objects.
These operator can also be used for addition, subtraction or comparison of class objects. For that purpose we have to define a function for each operator in class. Then function will behave as similar we will write in its destination.
The operator keyword and the symbol of operator is used to overload the specific operator. We can overload multiple operators for a single class.
C++ do not allow some operators for overloading these are as given.
1. :: Scope Resolution Operator
2. . Member Selection Operator
3. .* Member Selection Through Pointer
4. ?: Ternary Operator