Visibility

In class diagrams, visibility defines whether other classes can see and use the attributes and operations of specific classes.

For example, other classes can see and use the attributes and operations in a class with public visibility, while the attributes and operations with private visibility can be seen and used only by the class that contains them. 

As the following table illustrates, you can use decoration icons or text symbols to show the level of visibility for attributes and operations. A text symbol appended to the name of an association end shows the visibility of that association end.

Visibility level Icon for attribute Icon for operation Text symbol Description
Private An icon for a C/C++ private attirbute is displayed. An icon for a C/C++ private operation is displayed. - Only classes within the same container can see and use the classes with Private visibility.
Protected An icon for a C/C++ protected attribute is displayed. An icon for a C/C++ protected operation is displayed. # Only classes within the same container or a descendent of the container can see and use the classes with Protected visibility.
Public An icon for a C/C++ public attribute is displayed. An icon for a C/C++ public operation is displayed. + Any class that can see the container can also see and use the classes with Public visibility.

You can specify visibility styles for classifier features, including attributes and operations in class diagrams. You can specify the visibility styles by showing or hiding decoration icons (such as Image showing an Eclipse Protected visibility icon for operations.) and text symbols (such as #) that indicate the level of visibility for attributes and operations.

Related concepts
Class diagrams
Classes
Attributes
Operations
Multiplicity
Related tasks
Changing the default visibility style for attributes and operations
Changing the default visibility style for C/C++ stereotypes
Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.