Difficulty: Easy
Correct Answer: main()
Explanation:
Introduction / Context:
Default arguments in C++ let you omit trailing parameters at the call site. They are inserted by the compiler during overload resolution, which makes APIs more convenient while keeping type safety. However, not every function may carry default arguments. This item focuses on identifying the exception among common function categories: ordinary member functions of classes and structures versus the special program entry point, main().
Given Data / Assumptions:
Concept / Approach:
The syntax rules for default arguments apply broadly: free functions, member functions, and even function-pointer parameters can use them. The single notable outlier is the program's entry point. main() must conform to one of the permitted signatures (commonly int main() or int main(int, char**)), and the standard does not allow you to modify that interface with defaulted parameters. By contrast, class and struct member functions are fully eligible for default arguments because, in C++, struct and class have identical member function rules (only the default access differs).
Step-by-Step Solution:
Verification / Alternative check:
Attempt to declare int main(int argc = 0, char** argv = nullptr). Compilers reject this because main()'s signature is constrained. Conversely, adding defaults to a member function like void f(int x = 1) compiles and works as expected.
Why Other Options Are Wrong:
Member function of class — permitted; defaults are common in class APIs.
Member function of structure — permitted; structs follow the same rules.
Both B and C — incorrect because C is allowed while B is not.
Common Pitfalls:
Final Answer:
main()
Discussion & Comments