Difficulty: Easy
Correct Answer: Overloaded functions can accept same number of arguments.
Explanation:
Introduction / Context:
Function overloading lets you offer multiple functions with the same name but different parameter lists. The compiler chooses the best match based on argument types and counts at the call site. Clarifying what may differ (or remain the same) across overloads avoids myths about required differences in both arity and types, or about return types controlling overloading (they do not).
Given Data / Assumptions:
Concept / Approach:
Overloaded functions may have the same number of parameters and still overload successfully if the types differ (e.g., void f(int)
vs void f(double)
). They may also have a different number of parameters (e.g., arity 1 vs 2). What they cannot do is rely solely on differing return types; the parameter list must differ. Therefore, the correct statement is that overloaded functions can accept the same number of arguments (with different types).
Step-by-Step Solution:
Verification / Alternative check:
Compile examples above: the first two pairs succeed; the last fails. This demonstrates the real constraints on overloading.
Why Other Options Are Wrong:
“Always return same type”: return type does not govern overloading.
“Only same number and same type”: identical signatures would be redefinitions, not overloads.
“Only different number and different type”: too restrictive; types alone can differ with same count.
Common Pitfalls:
Final Answer:
Overloaded functions can accept same number of arguments.
Discussion & Comments