Difficulty: Easy
Correct Answer: class of the object using the function name
Explanation:
Introduction / Context:Name lookup and overload resolution in C++ proceed from the most specific scope outward. When invoking a member function on an object, the compiler tries to bind the call by first considering members of the object’s own (most-derived) class, then searching base classes as needed. This ordering affects which overload is chosen or whether a base member is hidden.
Given Data / Assumptions:
Concept / Approach:
Step-by-Step Solution:
Given obj.f(), search starts in type(obj).If no match, move to direct base(s), then ascend the hierarchy.Therefore, the first search location is the class of the object using the function name.Verification / Alternative check:
Test with a derived class redefining f(): the derived definition is chosen; removing it exposes the base version—confirming lookup order.Why Other Options Are Wrong:
Common Pitfalls:
Final Answer:
class of the object using the function name
Discussion & Comments