Function Overloading
- It is an oops concept, where one function name takes different arguments.
- Simply, Same function name different argument.
- C++ also permits overloading of functions.
- We overload the single function again and again, with different arguments.
- The argument count may change.
- The argument type may change.
Program:
#include<iostream.h>
class funover
{
public:
public:
void sum(int x, int y)
{
cout<<x+y;
}
void sum(int x, int y, int z)
cout<<x+y;
}
void sum(int x, int y, int z)
{
cout<< x+y+z;
}
};
cout<< x+y+z;
}
};
void main()
{
funover obj;
obj.sum(10,20);
obj.sum(10,20,30);
funover obj;
obj.sum(10,20);
obj.sum(10,20,30);
}