C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Pure Virtual Functions and Abstract Classes
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
     An abstract class is a class that contains at least one pure
     virtual function. Specify a virtual function as pure by placing
     = 0 at the end of its declaration. You don't have to supply a
     definition for a pure virtual function.
 
     You cannot declare an instance of an abstract base class; you
     can use it only as a base class when declaring other classes.
 
     In the following program, draw() is a pure virtual function
     defined in the abstract class Shape. You cannot declare Shape
     objects. Shape acts as a base class for Rectangle and Circle.
     Rectangle and Circle provide definitions for draw(), so you can
     declare instances of those classes and call draw() for them.
 
         #include <iostream.h>
 
         class Shape
         {
         public:
             virtual void draw() = 0;
         };
 
         class Rectangle: public Shape
         {
         public:
             void draw();
         };
 
         class Circle : public Shape
         {
         public:
             void draw();
         };
                                    -♦-