C++ Function Overloading


C++ also permits the overloading of functions, it means that we can use the same function name to create functions that perform a variety of different tasks.

Function Overloading in C++:

In Function Overloading, we can design a family of functions with one function name but with different argument lists. The function would perform different operations depending on the argument list in the function call.

Rules of Function Overloading in C++:

1. Functions have different parameter type.
2. Functions have a different number of parameters.
3. Functions have a different sequence of parameters.

C++ Function Overloading with example:


int area(int);
int area(int, int);
float area(float);
int main()
cout<<"The area of Square:"<<area(12)<<"\n";
cout<<"The area of Rectangle:"<<area(12,15)<<"\n";
cout<<"The area of Circle:"<<area(7)<<"\n";
return 0;
int area(int s)
int area(int l, int b)
float area(float r)

The area of Square: 144
The area of Rectangle: 180
The area of Circle: 153.86