[14.4] What does it mean that "friendship isn't inherited, transitive, or reciprocal"?
Just because I grant you friendship access to me doesn't automatically
grant your kids access to me, doesn't automatically grant your friends
access to me, and doesn't automatically grant me access to you.
- I don't necessarily trust the kids of my friends. The privileges of
friendship aren't inherited. Derived classes of a friend aren't necessarily
friends. If class Fred declares that class Base is a friend,
classes derived from Base don't have any automatic special access rights to
Fred objects.
- I don't necessarily trust the friends of my friends. The privileges
of friendship aren't transitive. A friend of a friend isn't necessarily a
friend. If class Fred declares class Wilma as a friend, and class
Wilma declares class Betty as a friend, class Betty doesn't
necessarily have any special access rights to Fred objects.
- You don't necessarily trust me simply because I declare you my
friend. The privileges of friendship aren't reciprocal. If class Fred
declares that class Wilma is a friend, Wilma objects have special access
to Fred objects but Fred objects do not automatically have special access
to Wilma objects.