Operations are implementations of functions or queries that an object might be called to perform. A well-defined operation does only one thing.
For example, you can make a Cart class responsible for adding and removing merchandise that a customer plans to buy. Then you can add an addItem() operation that adds merchandise to the cart and a removeItem( ) operation that removes merchandise.
In class diagrams, C/C++ methods map to UML class operations or behaviors.
As the figure in the following table illustrates, operations are shown in the operation compartment of a shape in a UML class diagram.
| C/C++ source code | UML visualization |
![]() |
![]() |
You can show, hide, or collapse the operation compartment, and show or
hide the compartment title. You can also specify the visibility styles of
operations as text symbols (such as "+") or icons (such as
).