Technical Discussion :: C++
Home > Freshers > Technical Interview Questions > C++
89. What is friend function?
Answer:
As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.
Asked In :: Aricent iGate Accenture
As the name suggests, the function acts as a friend to a class. As a friend of a class, it can access its private and protected members. A friend function is not a member of the class. But it must be listed in the class definition.
It’s possible to grant a non-member function access to the private members of a class by using the keyword friend. A friend function has access to all private and protected members of the class for which it is a friend.