c++ - What kind of function calling is this? -


this question has answer here:

i seeing code snippet saw calling of function not understand.it this

 void recursion(int v,int p=0)     //definition  {          //whatever in body  }     main()  {          //something ...          recursion(0);// *_*  } 

i taught in school calling , definition should have same number of arguments.but here not understand.it looks numbers of arguments can of different number.

that called default argument value. have specified after other arguments without default argument values.

then if don't specify argument in function call value used.

if have more 1 default argument, say:

void f(int first, int second = 0, char* third = ""); 

you have omit following default values if ommitting preceding one:

//you can f(0); f(1, 2); //but not f(1, "three"); 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -