Can anyone explain to me how do default argument values work in recursive functions in C++?

后端 未结 0 619
囚心锁ツ
囚心锁ツ 2020-11-27 09:26
int factorial ( int n, int a = 1 ) {
 if ( n == 0 ) return a;
 return factorial ( n-1, a * n );
}

This is a recursive function that calculates facto

相关标签:
回答
  • 消灭零回复
提交回复
热议问题