Summary: In this tutorial, we will learn about Function overloading in C++ with examples.

Introduction to Function Overloading in C++

When more than one function has the same name but different

  • Types of parameters,
  • OR Numbers of parameters,
  • OR Order of parameters.

then the functions are said to be overloaded.

Note: Return type is not considered as overloading criteria. Two functions with same name can have different return type.



Function Overloading in C++

The above example has 4 overloaded maxx functions.

Each function call in the main function is mapped to its respective overloaded maxx function during compile time depending on the function signature.

Function overloading is a property of Compile-time Polymorphism because binding of the function-call to the exact matching function is done during compile time only i.e. which version of the function should be called is decided during compile time.

Function overloading gives the power to use multiple data types and parameters under the same function name.

Leave a Reply