Function Overloading
Definition:
- In Function Overloading there are more than one functions with same name but different Parameters.
- This is Also called Static Isomorphism
- This is Also known as Compile time binding.
- In this the methods name will be same with different signature.
Example:
int add(int a, int b);
int add(int a, int b, int c);
void add(int a, float b, double c, int d);
Program
#include <iostream>
using namespace std;
int add(int n1, int n2)
{
int res;
res = n1+n2;
cout<<"\n Addition :\n"<<n1<<" + "<<n2<<" = "<<res;
}
int add(int n1,float n2, int n3)
{
float res;
res = n1+n2+n3;
cout<<"\n Addition :\n"<<n1<<" + "<<n2<<" + "<<n3<<" = "<<res;
}
int main()
{
add(10,20);
add(10.33,22.3,44.44);
return 0;
}
Comments
Post a Comment
If you have any doubts, Please let me Know