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:
packages: see Environment umlpackage for more details
classes: see Command \umlclass for more details
relationships between packages or classes: see Definition of relationships for more details
association classes: see Command \umlassocclass for more details
N-ary associations: see Command \umlNarynode for more details
notes: see Command \umlnote for more details
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