What is Function Overloading in C++ ?

October 28, 2007 · Filed Under C++ Questions, Placement Questions 



Don't want to miss a single bit? Subscribe By Email for Daily Jobs

Enter your email address :

All the latest from JobsAdda on Jobsadda.com delivered to your mailbox everyday.

Function overloading is the process of using the same name for two or more functions. However each function will be different in terms of either different types of parameters or a different number of parameters. It is only through these differences that the compiler knows which function to call in any given situation. Even if the number of parameters are same and types are same but they are written in a different order then these functions will still be considered different. The return type parameter does not hold any relevance to make two functions distinct.

E.g.

void display (int a);
void display (string str);

Both the above functions have the same name but different parameters. So when a function display (2) is called the compiler calls the first function and when the argument passed to display is a string then the second version is invoked.
E.g.

int display (int a );
void display (int a);

In the above example the compiler will generate a compile time error as the return types are insufficient to overload functions

Related Articles


Get Latest JobsAdda.com Jobs, news & updates  via Email