How are default arguments assigned when passing parameter values to a multiple-parameter function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How are default arguments assigned when passing parameter values to a multiple-parameter function?

Say for example my function takes the form of int myFunc(int x=1, int y=1, int z=1). If in the main function I were to use the following myFunc(0,1), are the passed arguments automatically assigned to x and y? And what if I were wanting to pass these values to say y and z instead?

25th Sep 2016, 5:57 AM
Rosemary Cicione
1 Answer
0
Yes, if you use myFunc(0,1) in your main function the values 0 ans 1 will be assigned to variable x and y respectively while the value of z will be set to 1 by default.
25th Sep 2016, 6:09 AM
Vinish