How can you use the default value of an argument when it is declared before the other parameters? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can you use the default value of an argument when it is declared before the other parameters?

func example(int a=1, int b=2) return a+b; int main(){ //how do you use the example function for a given value of b and the default value of a?

31st May 2017, 1:56 AM
Pacha
2 Answers
+ 4
ooo I misread. You would have to list b first. so int example(int b = 1, int a =1) example(3); Edit: example fixed
31st May 2017, 2:05 AM
jay
jay - avatar