Skip to content

Instantly share code, notes, and snippets.

@AhmedHelalAhmed
Created December 2, 2017 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AhmedHelalAhmed/547452558d7bce4c25ad503b3a185631 to your computer and use it in GitHub Desktop.
Save AhmedHelalAhmed/547452558d7bce4c25ad503b3a185631 to your computer and use it in GitHub Desktop.
default argument in C++
#include <iostream>
using namespace std;
void f(int x=0,int y=0,int z=0);
int main()
{
f(2);
f(1,2);
f(3,2,1);
return 0;
}
void f(int x,int y,int z)
{
if(x!=0)
{
cout<<"x= "<<x<<endl;
}
if(y!=0)
{
cout<<"y= "<<y<<endl;
}
if(z!=0)
{
cout<<"z= "<<z<<endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment