Well-designed classes encapsulate their functionality, hiding their implementation while providing a clean, documented interface. This allows redesign or change so long as the interface is unchanged.

In a more complex scenario, multiple classes that rely on each others’ implementation details may be required. Friend classes and functions allow these peers access to each others’ details, without compromising the encapsulation and information hiding of the documented interface.

Friend function

Friend method

Friend class