Friday 11 March 2016

Function Overloading In C++



Function Overloading In C++
C++ is an object oriented programming language. Polymorphism is one of the most important concept of object oriented programming language. Polymorphism means more than one form.
Polymorphism contains function overloading and operator overloading.
Function Overloading:
Same function name with different signatures is called function overloading.
i.e.  int Sum(int a, int b);
int   Sum(int a, int b, int c);
These two functions are c example of function overloading.
Both have same name Sum(), but have different no. of arguments.
Let us see another example, which have different data types:
void total(int a)
{ cout<<”total=”<<a;}
void total(float b)
{ cout<<”total=”<<b;}
void total(double c)
{ cout<<”total=”<<c; }
Here, in this example no. of arguments are same but data types of data are different.
So, both are called function overloading. There are same function name but no. of arguments are different in first example, in other example no. of argument same but data types are different.
To learn Basic Of C++

No comments:

Post a Comment