frienddeclaration lets a class specify that a function or class has access to its private or protected members. Avoid
frienddeclarations for loosely coupled classes because they control access at a very coarse granularity and don't specify what's acceptable and what's not (unless you document it). Taligent's preferred alternative is to define internal use only public member functions and denote with a comment what they are for (see "Class definition conventions" on page 63).
Friends make perfect sense for some situations, such as tightly coupled classes like TSetOf and TSetIteratorOver from the Collection classes. These classes are implemented in tandem and must know about one another's implementation, so it's appropriate to make them friend classes. Also, overloaded operators or functions must sometimes be global for symmetry, and therefore often must be declared as
friend. A Taligent engineer must confer with an architect before making
[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.