...
OOPS
August 29, 2024
OOPS
August 29, 2024
OOPS
August 29, 2024
OOPS
August 29, 2024

OOPS

Question 188
A friend function can be used to
A
avoid arguments between classes.
B
allow access to classes whose source code is unavailable.
C
allow one class to access an unrelated class.
D
None of the above
Question 188 Explanation: 
A friend function of a class is defined outside that class scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
→A function can only be declared a friend by a class itself.
→It can have access to all members of the class, even private ones.
→ A friend function can be used to allow one class to access an unrelated class.
Correct Answer: C
Question 188 Explanation: 
A friend function of a class is defined outside that class scope but it has the right to access all private and protected members of the class. Even though the prototypes for friend functions appear in the class definition, friends are not member functions.
→A function can only be declared a friend by a class itself.
→It can have access to all members of the class, even private ones.
→ A friend function can be used to allow one class to access an unrelated class.

Leave a Reply

Your email address will not be published. Required fields are marked *