[Next] [Prev] [Up] [Top]

7.0 Classes

Do not use friends haphazardly (GL)


Friends should be used when there is a strong codependency between a class and another entiry (class, function, or method).

Some features do not make sense as part of a public abstraction. Rather than making such a feature public, use a friend instead.

Grant access using the most restrictive case first. For example, prefer friend methods over friend classes.

Note that a common C++ idiom uses friend functions (particularly operators) to achieve symmetrical type conversions.


No Title
[Next] [Prev] [Up] [Top]

Generated with CERN WebMaker

This site was grabbed using the TRIAL version of Grab-a-Site. This message does not appear on a licensed copy of Grab-a-Site.