Function Overloading, Function in C++
Simple example of Function Overloading in C++:

Program Code:
#include <iostream>
using namespace std;
int sum (int x, int y)
{
 cout << x+y;
}
int sum(int x, int y, int z)
{
 cout << x+y+z;
}
int main()
{
sum (10,20);  // sum() with 2 parameter will be called
sum(10,20,30);  //sum() with 3 parameter will be called
}


The output of the program is tested on www.jdoodle.com
Output:
30
60


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: