Difficulty: Easy
Correct Answer: Default argument cannot be provided for pointers to functions.
Explanation:
Introduction / Context:
Default arguments in C++ let callers omit trailing parameters. They are inserted by the compiler at the call site. Understanding where defaults are allowed and the one-definition rules prevents ambiguous interfaces and linker surprises—especially in multi-declaration scenarios and for function-pointer parameters.
Given Data / Assumptions:
Concept / Approach:
Default arguments may be supplied for any parameter, including a pointer-to-function parameter: e.g., void f(int, int (*pf)() = nullptr);
. An entire parameter list may be defaulted, making the function callable with no arguments. However, a default argument must be specified only once for a given parameter across declarations; redeclaring a different default later is ill-formed. Therefore, the incorrect statement is the claim that “Default argument cannot be provided for pointers to functions.” It can be provided.
Step-by-Step Solution:
Verification / Alternative check:
Compile a sample where a function-pointer parameter has a default. It compiles. Add a second declaration that attempts to change the default and observe a compile-time error, confirming D and refuting C.
Why Other Options Are Wrong:
Labelled “wrong” here means “not the incorrect statement.” A, B, and D are all accurate rules of C++ defaults.
Common Pitfalls:
Final Answer:
Default argument cannot be provided for pointers to functions.
Discussion & Comments