Question
Easy

In context of C++, consider the following statements: I: Friend function of a class can directly access both private and protected data of the class. II: Member function of derived class can directly access both private and protected data of the class. The true statement(s) is/are:

1
Only I
2
Only II
3
Both I and II
4
Neither I Nor II
Question Details
Time to Solve: 12
Exam: HTET
Level/Paper: Level 3
Chapter: Object-Oriented Programming (C++)
Topic: Advanced Class Concepts
Correct Answer
Option A
Explanation

The correct option is (1): Statement I is a fundamental definition of the 'friend' mechanism in C++. A function (or another class) explicitly declared as a friend inside a class is a designated exception to the standard encapsulation rules. This special friendship status grants the function the highest level of access, allowing it to bypass normal member access restrictions and directly manipulate both the private and protected data members of…Read More