/*function overloading
**********************/
/*when same function name is existing multiple time in a class with different number of
parameters or with different order of parameter or with differnt type of parameters is known as
function overloading*/
#include<iostream>
using namespace std;
class overloading
{
public:
void sum(int x,int y) //smae name same return type but different number of parameters
{
cout<<"int int"<<endl;
}
void sum(double x,double y) //same name same return time but different type of parameters
{
cout<<"double double"<<endl;
}
void sum(int x,int y,int z) //same name same return type but different number of parameters
{
cout<<"int int int"<<endl;
}
};
int main()
{
overloading obj;
obj.sum(2,2,9);
}
No comments:
Post a Comment