Simple example of Function Overloading in C++ having different datatypes of argument:
Program Code:
#include <iostream>
using namespace std;
int sum(int x,int y)
{
cout<< x+y;
}
double sum(double x,double y)
{
cout << x+y;
}
int main()
{
sum (10,20);
sum(10.55,20.15);
}
The output of the program is tested on www.jdoodle.com
Output:
30
30.70
Thanks
Mukesh Rajput
Post A Comment:
0 comments: