Overloading in c++
If we create two or more members having the same name but different in number or type of parameter, it is known as C++ overloading. In C++, we can overload:
➦This means C++ has the ability to provide the operators with a special meaning for a data type, this ability is known as operator overloading.
➦For example, we can overload an operator ‘+’ in a class like String so that we can concatenate two strings by just using+.
Types of Overloading ?
function Overloading :
➦Function Overloading is defined as the process of having two or more function with the same name, but different in parameters is known as function overloading in C++. In function overloading, the function is redefined by using either different types of arguments or a different number of arguments. It is only through these differences compiler can differentiate between the functions.
Operator Overloading ?
➦Operator overloading is a compile-time polymorphism in which the operator is overloaded to provide the special meaning to the user-defined data type. Operator overloading is used to overload or redefines most of the operators available in C++. It is used to perform the operation on the user-defined data type. For example, C++ provides the ability to add the variables of the user-defined data type that is applied to the built-in data types.
Example: Function Overloading :
Example: Operator Overloading :