What is a friend function?
Show answer and explanation
A friend function is not a member function, but a friend declaration grants it access to a class's private and protected members. Friendship is explicit, neither inherited nor transitive, and does not grant friendship in the reverse direction. It is useful for tightly coupled non-member operations such as symmetric operators, but broad friendship increases coupling and should not replace a well-designed public interface.
A friend function is not a member function, but a friend declaration grants it access to a class's private and protected members. Friendship is explicit, neither inherited nor transitive, and does not grant friendship in the reverse direction. It is useful for tightly coupled non-member operations such as symmetric operators, but broad friendship increases coupling and should not replace a well-designed public interface.
Connect the conclusion directly to the type, lifetime, ownership, overload-resolution rule, or library contract present in the question. State implementation dependence or a violated precondition explicitly instead of merely guessing output.