default argument, default argument in functions, Function Overloading in C++
Simple example of Function Overloading in C++ having default  argument:


Program Code:
#include <iostream>
using namespace std;
void sum(int x,int y= 50) // here 50 is a default argument
{
cout << x+y;
}
int main()
{ 

sum(10);
sum(10,0);
sum(10,10);
}


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


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: