What is function overloading? Discuss this.

Function Overloading: Overloading refers to the use of the same thing for different purposes. When the same name for different functions is used that is called function overloading. The functions are then distinguished by their parameters or argument lists.
Functions can be overloaded by changing, increasing or decreasing their arguments,

float add(float a, float b)
int add(int a, int b)
int add(int a)
int add(int a, int b, int c)

By changing their argument’s sequence like,

double add(int a, double b)
double add(double a, int b)

Following is a program example using function overloading,

//function overloading

class overload{
int a,b;
float c,d;
int add(int x, int y){ //function 1
return x*x+y*y;
float add(float x,float y){ //function 2
return (x+x)*(y+y);

void main(){
overload ob1;
cout<<ob1.add(5,5)<<"n"; //calling function 1 here
cout<<ob1.add(5.5f,5.5f); //calling function 2 here


Here both function 1 and 2 are of the same name add but their arguments are different. Thus they are treated as two different functions.


No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published.