When to use pure virtual functions

The presence of the keyword virtual does not mean that a function can be overridden. This must be explicitly stated in the class specification. A pure virtual function, however, is an exception. Declare a pure virtual function like this:

      class TAbstract {
         virtual void MustOverride() = 0;
Before a concrete class (one that can be instantiated) can be created, all pure virtual functions
that it contains must be overridden. This is valuable both for documentation and for forcing compile-time checking.

[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