Syntax of a Derived Class Declaration

The syntax for the list of base classes is:

>>--derived_class--:-->
   /-,---------------------------------------------------------\
                                                              |
>------------------------------------qualified_class_specifier----><
     |-virtual--------------------|
     |          |-public----|     |
     |          |-private---|     |
     |          \-protected-/     |
     \---public-------------------/
       |-private---|  \-virtual-/
       \-protected-/

The qualified class specifier must be a class that has been previously declared in a class declaration.

The virtual keyword can be used to declare virtual base classes.

The following example shows the declaration of the derived class D and the base classes V, B1, and B2. The class B1 is both a base class and a derived class because it is derived from class V and is a base class for D.

class V { /* ... */ };
class B1 : virtual public V { /* ... */ };
class B2 { /* ... */ };
class D : public B1, private B2 { /* ... */ };