C++ | Function Overloading

Join Programming and Development Chat Groups on Uphub.io


The tutorial is to understand the function overloading. C++ gives the user the advantage to create functions with same name but different function prototype, This is definition of function overloading. The program given below has same name but different prototype. The program is extendable. Go enjoy the program. Lets begin……..

Program for function overloading

//function prototype
float area(float);
int area(int);
int area(int,int);
//main function
void main()
//clear the screen.
//declare variables as int.
int a,l,b;
float r;
//Input the radius, sides and length and breadth.
cout<<"Enter the radius of circle"<<endl;
cout<<"Enter the side of square"<<endl;
cout<<"Enter the length and breadth of rectangle"<<endl;
//calculate area using functions and print it.
cout<<"Area of circle is "<<area(r)<<endl;
cout<<"Area of square is "<<area(a)<<endl;
cout<<"Area of rectangle is "<<area(l,b)<<endl;
//get character

float area(float x)
float area;

int area(int x)
int area;

int area(int x,int y)
int area;


Enter the radius of circle
Enter the side of square
Enter the length and breadth of rectangle
Area of circle is 3.14
Area of square is 25
Area of rectangle is 20

How does it work

  1. You enter the necessary inputs.
  2. The function calculates the area.
  3. The area is printed.

Extending it

The program can be extended by using more different shapes of geometry. You can take the necessary inputs and calculate the area of the given geometry and add there respective functions at end. Even you can do the same program to find the perimeter of different shapes.

  • Remember this is a basic part of c++ which can be used in any program….


  1. Include ‘iostream.h’ and ‘conio.h’ files.
  2. Declare the function prototype.
  3. Add void main.
  4. Start program by first clearing the screen.
  5. Declare the variables as int (name them as you want.)
  6. Add the cout and cin of necessary shapes.
  7. Add the cout of area and call the function.
  8. Add the function definition outside the void main().

At the end

You learnt creating the C++ program for Function overloading. So now enjoy the program.

Please comment on the post and share it.
And like it if you liked.

Sharing options: