A friend function is declared by the class that is granting access, explicitly stating what function from a class is allowed access. A similar concept is that of [[friend class]].
Friends should be used with caution. Too many functions or external classes declared as friends of a class with protected or private (visibility modes) data may lessen the value of [[separation of concerns|encapsulation]] of separate classes in object-oriented programming and may indicate a problem in the overall architecture design. GenerallyIt though,may friendalso functionslead areto atight good thing for encapsulation, as you can keep datacoupling of a class private from all except those who you explicitly state need it, but this does mean your classes will become tightly coupled.