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:
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
Source :
Source :
Source :
Source :