Empty base classes

An empty base class occurs when an abstract base class has no member functions other than the constructor and destructor (or other special members). Many developers create such base classes because there is some idea they want to have represented by a class, even though it has no protocol.

Base classes (especially public ones) should exist only if there is protocol to be inherited. Public bases should only exist if they are to be used polymorphically. If there is no such protocol, there is no type relationship (or behavior inheritance), and there is no need for a base class. If you wind up in this situation, rethink your class hierarchy. Not every idea needs to be expressed as a class, and classes don't always correspond one-to-one with real-world entities.

[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker