Created
December 2, 2017 11:05
-
-
Save AhmedHelalAhmed/547452558d7bce4c25ad503b3a185631 to your computer and use it in GitHub Desktop.
default argument in C++
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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