C++ Function Overloading

 

Function Overloading

Function overloading is a process to make more than one function with the same name but different parameters, numbers, or sequences. Now, there are a few conditions and any number of functions with the same name following any of these are called overloaded.

Same name but different data type of parameters

Example

float sum(int a, int b);
float sum(float a, float b);

 

Same name but a different number of parameters

Example

float sum(int a, int b);
float sum(int a, int b, int c);

 

Same name but different parameter sequence

Example

float sum(int a, float b);
float sum(float a, int b);

Exact matches are always preferred while looking for a function that has the same set of parameters.