Define class abstractions

For the client to be able override a virtual function, you must make a clear definition of what the function does, even if the client only calls the inherited version after a little processing. The class must specify whether and how virtual functions can be overridden, and what the derived class' responsibilities are.

The presence of virtual or protected is not enough to define the interface seen by a derived class, just as a class definition by itself is not enough to specify the interface seen by clients. The interfaces seen by clients and derived classes have a semantic component as well as a syntactic one; the C++ syntax often expresses only a small fraction of the total interface. If a function can be overridden, you must state so explicitly in the class specification (unless it's a pure virtual function). Your interface must be thought through and well documented. The next two sections go into more detail.

[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