March 15, 2011, 7:57 p.m.
posted by madinteger
DiscussionNonmember nonfriend functions improve encapsulation by minimizing dependencies: The body of the function cannot come to depend on the nonpublic members of the class (see Item 11). They also break apart monolithic classes to liberate separable functionality, further reducing coupling (see Item 33). They improve genericity, because it's hard to write templates that don't know whether or not an operation is a member for a given type (see Item 67). Use this algorithm to determine whether a function should be a member and/or friend:
|
- Comment