Function overloading varying in number of arguments
: Two functions with same names but with different no. of parameters of the same type are used in this type of function overloading. For example, in the below mentioned example two sum() functions are mentioned to return sum of two and three integers which is nothing but the sum() is overloaded and depends on no.of arguments.
[c]
int splessons (int a, int b)
{
cout << a+b;
}
int splessons(int a, int b, int c)
{
cout << a+b+c;
}
[/c]
Function overloading varying in type of arguments
: Two or more functions with same name and same number of parameters, but parameter type is different. For example, let there be two sum() functions, first has two integer arguments and second one has two double arguments.
[c]
int splessons(int a,int b)
{
cout << a+b;
}
double splessons(double a,double b)
{
cout << a+b;
}
[/c]