Difficulty: Easy
Correct Answer: The function main
Explanation:
Introduction / Context:
Function overloading in C++ permits multiple functions with the same name to co-exist in the same scope as long as their parameter lists differ. However, not every function name in a program is eligible for overloading. Recognizing the exceptions prevents invalid API designs and linker conflicts.
Given Data / Assumptions:
Concept / Approach:
The program entry point main
has a unique, implementation-defined signature (commonly int main()
or int main(int, char**)
) and cannot be overloaded. By contrast, ordinary member functions (including static and virtual) may be overloaded within their class scope by providing different parameter lists. Note that “virtual” concerns overriding across a hierarchy, which is orthogonal to overloading within the same scope.
Step-by-Step Solution:
Verification / Alternative check:
Attempt to provide two main definitions with different parameters; the program is ill-formed. In a class, define several functions with the same name but different parameters (static or non-static, virtual or not) and they overload successfully in that class scope.
Why Other Options Are Wrong:
Non-static, static, and virtual members may all be overloaded (overriding is a different concept for virtuals).
Common Pitfalls:
Final Answer:
The function main
Discussion & Comments