Permission relationships

In class diagrams, a permission relationship is a relationship in which a class allows another class to have visibility to its encapsulated attributes or operations.

In C/C++ a special relationship allows one class to give permission to another class to access its private data area. The class that has been given permission becomes a friend to the sharing class. A class that is a friend to another class has access to all the data and methods of the sharing class.

For example, a Customer class gives permission to an Account class so that the Account class can use personal information about the customer. The Account class becomes a friend to the Customer class. This relationship makes it easier for the Account class to perform its tasks because it has access to the Customer class.

Note: Permission relationships in C/C++ circumvent data encapsulation and might break the intended design of a class or classes. Friends in C/C++ and should be used with caution.

As the figure in the following table illustrates, a permission relationship is shown by a dashed line connector between classes with an open arrowhead that points to the friend class, or the class that has permission to access the private data and methods of the sharing class.

C/C++ source code UML visualization
A snapshot of C/C++ code illustrating a permission relationship. A C/C++ permission relationship is displayed.
Related concepts
Association relationships
Dependency relationships
Generalization relationships
Manifestation relationships
Owned element association relationships
Abstract generalization
Adornments for unresolved references
Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.