Default Arguments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Default Arguments

"any defaults should be on the right side of any non-default arguments; otherwise, things will not work as expected"..... What does this statement mean?

28th Feb 2017, 6:12 PM
abu maimuna
abu maimuna - avatar
1 Answer
+ 1
1. func (int x, int y=3) 2. func (int x=3, int y) means it should be like 1. you see default argument is right side of non-default argument x. and 2. will not work as expected. this is what I means. (x, y=4, z=7) fine (x=3, y, z=5) doesn't work properly hope now you understand what does this line say
28th Feb 2017, 6:22 PM
Raj Kumar Chauhan
Raj Kumar Chauhan - avatar