Overloaded Functions


  • Two functions that appear in the same scope are overloaded if they have the same name but have different parameter lists.
  • Function overloading can make programs easier to write and to understand by eliminating the need to invent—and remember—names that exist only to help the compiler figure out which function to call.
  • Functions cannot be overloaded based only on differences in the return type.

Function Matching and Argument Conversions

Function overload resolution (also known as function matching) is the process by which a function call is associated with a specific function from a set of overloaded functions. The compiler matches a call to a function automatically by comparing the actual arguments used in the call with the parameters offered by each function in the overload set.


int Add(int nX, int nY); // integer version
double Add(double dX, double dY); // floating point version
int Add(int nX, int nY, int nZ); // even with a different number of parameters
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.