A.4.4 Conditional Inheritance

Conditional inheritance is an extension to multiple inheritance. Several base-sections can be specified separated by commas. Each base-section can be given a condition in the form of an expression. The base-section is passed on to the section when the condition evaluates to true. If no condition is given for a base-section the base-section is always included.

In the following example Section23 is always derived from SectionA. Additionally, depending on the value of twoPointSwitch either SectionB, SectionC, or both are used as base-sections.

twoPointSwitch = 0;

Section23 : SectionA,     // always used
            SectionB ? (twoPointSwitch > -1),
            SectionC ? (twoPointSwitch <  1)
{  // ...
}

Robert Klima 2003-02-06