Which of the following is not a member of class ?

2014

Which of the following is not a member of class ?

  1. A.

    Static function

  2. B.

    Friend function

  3. C.

    Const function

  4. D.

    Virtual function

Attempted by 438 students.

Show answer & explanation

Correct answer: B

Answer: Friend function is not a member of the class.

Explanation:

  • Friend function: Not a class member. Declaring a function as a friend gives that external function access to the class's private and protected members, but the function itself is defined outside the class and is not part of its member set.

  • Static function: A class member function marked static. It belongs to the class rather than to instances and can access only static members.

  • Const function: A member function declared with the const qualifier that promises not to modify the object; it is part of the class's members.

  • Virtual function: A member function declared virtual to support runtime polymorphism; it is a member of the class and can be overridden in derived classes.

Key point: A friend function can access a class's internals by declaration, but it remains a non-member function defined outside the class.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor