11. Virtual classes

In section , we introduced virtual methods, which are methods that are partially specified in a class and their specification may be extended in subclasses of the class where they are declared.

We may in a similar way define virtual classes, which are classes that are partially specified in a given class and its description may be further extended in subclasses and singular objects subclassed from the class. A virtual class may be defined as a local attribute or as a parameter.

A virtual classes exist in two forms self-constrained and class-constrained. As first example, we show how to use a self-constrained virtual class in a restructuring of the travel booking system. Then we show how to use a class-constrained virtual class to define class Set as introduce in chapter . Finally, an example from the domain of graphs is shown.