Multiple parameters in C++ functions

I just stepped into the functions section of C++ and I’m at a part teaching me about using or having multiple parameters.

This is the specific section.

image

You can see it says that you can use as many parameters as you want but you must remember their order when you call the function. Does this mean to type them in the matching order when calling? Or is there a specific order that the parameters need to be placed in when declaring them?

It goes on to show a right and wrong way to call the function, but does not explain exactly why one is right and one is wrong.

I mean it does say which order to put them in but not why. Is it because the bool needs to be last? Or just that the price needs to be before the tip?
Just wanted to clarify.

Order matters for calling. Another important bit:

In a function declaration, after a parameter with a default argument, all subsequent parameters must: have a default argument supplied in this or a previous declaration from the same scope:

Documentation is key. C++ is very technical and so is its documentation:

https://en.cppreference.com/w/cpp/language/default_arguments

1 Like

thank you for your response. So what is the correct order for calling? Is it just to match the order when it was created? Or is there a specific order that the parameters need to be in, like order of operations?

Same calling order as created without a doubt.