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.

Advanced options of \umlclass#

Tagged values#

To add tagged values to a class, you can use the option tags:

\umlemptyclass[tags={v1.2}]{class-name}

Figure made with TikZ

Figure made with TikZ

Template parameters#

For a template class, you can use the template option to specify the template parameters list:

\umlemptyclass[template={T,U}]{class-name}

Figure made with TikZ

Figure made with TikZ

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 $\rightarrow$ int}]{A}{B}

Figure made with TikZ

Figure made with TikZ