Difficulty: Easy
Correct Answer: Friend function
Explanation:
Introduction:
Classes can contain many kinds of members: data, functions (including static, const-qualified, and virtual). C++ also has the notion of friends that can access private parts without being members. This question tests your understanding of that distinction.
Given Data / Assumptions:
Concept / Approach:
A friend function is not a class member. It remains a free function (or a function of another class) but is granted access to private and protected members of the declaring class. By contrast, a static member function is a true member without a this pointer; a const member function is a member whose implicit object parameter is const; a virtual function is a member participating in dynamic dispatch.
Step-by-Step Solution:
1) Identify which candidates are intrinsically members (static, const-qualified, virtual).2) Recall that friend affects access, not membership.3) Conclude that “Friend function” is not a member.4) Therefore, select option B.
Verification / Alternative check:
Use ADL and fully qualified names to note that friend functions are defined at namespace scope (unless they are also declared as members separately).
Why Other Options Are Wrong:
Static function: declared inside the class; it is a member.Const function: still a member; const qualifies the implicit object parameter.Virtual function: always a non-static member participating in virtual dispatch.
Common Pitfalls:
Assuming a friend “belongs” to the class. It does not; it only gains access privileges.
Final Answer:
Friend function
Discussion & Comments