All mock tests are FREE till 31 December — register to save your progress

Statement (I): A friend function and the member functions of a friend class can directly access private and protected data.
Statement (II): A friend function can access private data through the member functions of the base class.
In the light of the above statements, choose the most appropriate answer from the options given below:

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: A. Both Statement I and Statement II are correct

Explanation

Friends get direct access to private/protected members (I). Like any function, a friend can also reach private data through the class's public member functions (II). The keyed answer treats both as correct.

More Programming Languages and Computer Graphics questions