O'Reilly logo

Extended STL, Volume 1: Collections and Iterators by Matthew Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required