In C++, if a function f is defined as a friend function, then which of the…

2018

In C++, if a function f is defined as a friend function, then which of the following category of data members can be accessed using the function f ?

Answer: D. Public, Private and ProtectedIn C++, a friend function is declared outside the class but granted special access privileges. It can access all data members of the class, including private,…

  1. A.

    Only Private

  2. B.

    Only Protected

  3. C.

    Only Public

  4. D.

    Public, Private and Protected

Attempted by 492 students.

Show answer & explanation

Correct answer: D

In C++, a friend function is declared outside the class but granted special access privileges. It can access all data members of the class, including private, protected, and public categories.

Explore the full course: Rssb Basic Computer Instructor

Loading lesson…