Which C++ function declaration is INVALID because of its default argument?
Correct answer C. void f(int a = 1, int b);
Explanation
In a function declaration, once a parameter has a default argument, every parameter after it must also have one (or receive one from an earlier declaration). void f(int a = 1, int b) breaks this rule, because b has no default after a defaulted parameter. The rule exists because arguments are matched from left to right, so callers can only omit trailing arguments.
Answer checked How we write and check questions
Discussion