Friend function: Difference between revisions

Content deleted Content added
m Reverting possible vandalism by 210.212.161.97 to version by Kendev55. Report False Positive? Thanks, ClueBot NG. (2527287) (Bot)
No edit summary
Line 6:
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. Generally though, friend functions are a good thing for encapsulation, as you can keep data of a class private from all except those who you explicitly state need it, but this does mean your classes will become tightly coupled.
 
==Use cases==