What is Function overloading?

Fuction overloading means defining more than one function having same name in a class or defining multiple functions of same name. Function overloading is used to define same name functions that perform similar operations on different data types of arguments and in this way it implements polymorphism because a single function name is used for performing multiple operations. In case of function overloading, compiler calls the different functions by checking their data type, the number of arguments of the functions, their order in the function call and function definition.

E.g. of Function Overloading:
Class area
{
Double ar;
Public:
Void Area(int s)
{
Ar=s*s;
}
Void Area(int l,int b)
{
Ar=l*b;
}
Void Area(float r);
{
Ar=3.142*r*r;
}

More Questions

Leave a Reply

Word Verfication * Time limit is exhausted. Please reload CAPTCHA.