Chapter 15. The Independent Autonomies of equal() Friends

 

True friendship is never serene.

 
 --Marquise de Sévigné

In The Ethics, Aristotle writes of friendships, both between equal friends and between unequal friends, and discusses the mutual responsibilities and obligations necessary to maintain healthy relationships. In this short chapter, I intend to show how avoiding friendship simplifies implementations and avoids unnecessary breaking of encapsulation.

Beware Nonmember Friend Function Abuse

Scott Meyers’ principle of the use of nonmember functions over member functions as a tactic for increasing encapsulation is both worthy and widely employed. I follow this whenever it’s appropriate. There’s a common and totally unnecessary abuse of this principle, ...

Get Extended STL, Volume 1: Collections and Iterators now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.