What is Function Overloading in C++ ?
![]() Don't want to miss a single bit? Subscribe By Email for Daily Jobs |
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
- What do you mean by “Pointers to Function”? What are Function Pointers ?
- What is the Difference between Overloaded Functions and Overridden Functions ?
- What are Virtual Functions ? Why do we need Virtual Functions? Explain with an example.
- What are Inline Functions ? When are Inline Functions used ?
- What is Polymorphism ? How is Polymorphism achieved in C++ ?


