Created
December 2, 2017 11:12
-
-
Save AhmedHelalAhmed/149ed933fb5c0c41df317ae70fc28e32 to your computer and use it in GitHub Desktop.
default argument condition
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; | |
/* | |
int f(int x,int y=1,int z); | |
it will generate error | |
when default argument starts it must be to the end | |
*/ | |
int f(int x,int y=1,int z=1); | |
int main() | |
{ | |
int v1,v2,v3; | |
v1=f(1,2,3); | |
cout<<v1<<endl; | |
v2=f(3,2); | |
cout<<v2<<endl; | |
v3=f(2); | |
cout<<v3<<endl; | |
return 0; | |
} | |
int f(int x,int y,int z) | |
{ | |
cout<<"x= "<<x<<endl; | |
cout<<"y= "<<y<<endl; | |
cout<<"z= "<<z<<endl; | |
return x*y*z; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment