C++ Overloading (Function and Operator)
If we create two or more members having same name but different in number or type of parameter, it is known as C++ overloading. In C++, we can overload:
It is because these members have parameters only.
Types of overloading in C++ are:
C++ Function Overloading
Having two or more function with same name but different in parameters, is known as function overloading in C++.
The advantage of Function overloading is that it increases the readability of the program because you don't need to use different names for same action.
C++ Function Overloading Example
Let's see the simple example of function overloading where we are changing number of arguments of add() method.
C++ Operators Overloading
Operator overloading is used to overload or redefine most of the operators available in C++. It is used to perform operation on user define data type.
The advantage of Operators overloading is to perform different operations on the same operand.
C++ Operators Overloading Example
Let's see the simple example of operator overloading in C++. In this example, void operator ++ () operator function is defined (inside Test class).
The Count is: 10