Base-Class Composition with
Multiple Derivation and Virtual Bases
Lee R. Nackman and John J. Barton
IBM Research Division
Thomas J. Watson Research Center
P.O. Box 704
Yorktown Heights, New York 10598
lrn@watson.ibm.com and jjb@watson.ibm.com
Abstract
For systems of C++ classes using virtual functions, writing base
classes that only specify virtual member functions and then writing
other base classes that only implement those functions improves
extensibility. When interface is separated from implementation, both
interfaces and implementations can be extended separately by
derivation. New classes can then be composed by multiple derivation,
combining one interface and one implementation base class. We call
this form of composition base-class composition.
Programmers familiar with the advantages of base-class composition
fail to use it because of the performance penalty of multiple
derivation and virtual base classes. Consequently, compiler writers,
failing to see extensive applications of multiple derivation and
virtual bases, have little incentive to eliminate the performance
penalty. We highlight the advantages of the base-class composition
pattern and show how the performance penalty can be eliminated by
Download the full text of this paper in
ASCII (48,064 bytes) and
POSTSCRIPT (172,726 bytes) form.
To Become a USENIX Member, please see our
Membership Information.