Class diagrams#

Package and class diagrams are used to represent the structure of classes and packages in object-oriented programming. They show the packages, the classes, their attributes, methods, and the relationships between them. In such diagrams, you will find:

In the following, we will explain advanced features.

To define a specialization of a class#

A specialization of a class is an inheritance from a template class in which one of the template parameters is defined. To draw this relation, you will use the \umlrealize command, and its stereo option:

\umlemptyclass[template=T]{A}
\umlemptyclass[template={T,U}, x=5, y=-2]{B}
\umlrealize[stereo={U \ensuremath{\rightarrow} int}]{A}{B}
%\umlrealize[stereo={U $\rightarrow$ int}]{A}{B} % works
%\umlrealize[stereo={U \(\rightarrow\) int}]{A}{B} % does not work

Figure made with TikZ

Figure made with TikZ