Go to the first, previous, next, last section, table of contents.


7.8 Specifying Derived Classes

One can specify that a class is to be derived from some other class using the same syntax as in C++ (chapter 10 of [Ellis-Stroustrup90]). Thus the syntax of the base-spec of a class-specifier is as follows. See section 7.2 Class Member Specifications for the syntax of access-specifier. See section 5.2.3.2 Class and Namespace Names for the syntax of complete-class-name.

base-spec ::= : base-list
base-list ::= base-specifier [ , base-specifier ] ...
base-specifier ::= [ virtual ] [ access-specifier ] complete-class-name
        | access-specifier [ virtual ] complete-class-name

All of this is part of the interface specified for a class in Larch/C++. For a C++ class to satisfy this part of the specified interface, it must have at least the base classes listed, in the base-list (with the specified access-specifiers and virtual attributes). A C++ class satisfying a Larch/C++ specification may have more than the listed base classes. In particular, it may have more private and protected base classes, as these are not usually of concern to clients. See section 10.3 Specifying Protected and Private Interfaces for a discussion of when you might want to specify such information about an implementation.

Whether a base class is declared to be public has an impact on the C++ type system (section 4.6 of [Ellis-Stroustrup90]). It also has an impact on the meaning of the specification, through specification inheritance (see section 7.9 Inheritance of Specifications and Subtyping).

Recall that the default access-specifier for the base in a class declaration is private (section 11.2 of [Ellis-Stroustrup90]). Good style recommends explicitly specifying giving the access-specifier for all base classes.


Go to the first, previous, next, last section, table of contents.