What is Function Overloading

What is Function Overloading


Rajesh kumar
Views: 815 | Community Opinion: 1

Tags..  object oriented programming

Bookmark this page..



Ask a New Question Go to Home

Community Opinion/Answers
 

Function overloading is the practice of declaring the same function with different signatures. The same function name will be used with different number of parameters and parameters of different type. But overloading of functions with different return types are not allowed. Like

void f(char c, int i);
void f(int i, char c);
void f(string & s);


For example, a print function that takes a string (or char *) argument performs very different tasks than one that takes an argument of type double. Overloading permits uniform naming and prevents programmers from having to invent names such as print_sz or print_d.


Function Declaration Element used for Overloading?

Function return type - No

Number of arguments - Yes

Type of arguments - Yes

Presence or absence of ellipsis - Yes

Use of typedef names - No

Unspecified array bounds - No

const or volatile - Yes






Register or Login to Post Your Opinion