C++ Overloading

C++ Overloading is a condition when two or more members have the same name with different parameter type or a different number of parameter. C++ overloading is two types:

  1. Function overloading
  2. Operator overloading

 

C++ Function Overloading

When two or more function having the same name are different in their parameter is called function overloading.

C++ Function Overloading Example

This example calculates the area of two different polygons.

Output:

 

C++ Operator Overloading

C++ provides the functionality to redefine or overload the existing operators in C++. Operator overloading is used to perform an operation on user define the data type.

C++ Operator Overloading Example

Output:

Leave a Comment