I am a student learning C++. I am creating a UML class diagram for my program that involves inheritance and abstract / concrete classes, but I'm not too sure how I would denote a pure virtual function. Any help is appreciated, thank you!
You declare a pure virtual function by using a pure specifier ( = 0 ) in the declaration of a virtual member function in the class declaration. Class A is an abstract class. The compiler would not allow the function declarations A g() or void h(A) , declaration of object a , nor the static cast of b to type A .
Normally, UML indicates virtual functions via italics.
A pure virtual function is a virtual function in C++ for which we need not to write any function definition and only we have to declare it. It is declared by assigning 0 in the declaration. An abstract class is a class in C++ which have at least one pure virtual function.
The UML standard does indicate that a behavioral feature (e.g. a method/operation) can have its property isAbstract
set to indicate that it is abstract and has no implementation. There is however nothing about how this should be shown in the diagram.
According to uml-diagrams.org and other sources, in older UML versions (1.4.x), an abstract operation was shown with a name in italic or with a textual {abstract}
marker following its name. The italic convention was widely used (See also here).
The current UML doesn't use anymore use italic and does not indicate how to represent the isAbstract
property. Nevertheless, the {abstract}
marker should still be valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With