Last Updated: February 25, 2016
·
890
· lokiastari

C++: Friends are welcome but choose them judiciously.

C++ friends can see your internals.
But characterizing the scope of friendship is not always easy. Most new developers fall foul of friendship not being inherited but we can use the parent as a proxy and allow access via a protected parental control :-)

One of the main complaints is friendship breaks encapsulation. This is not true; friendship increases encapsulation by tightly coupling the friend and making it part of the public interface.