The DrawFigure class
The Draw
class is the root class of the hierarchy and is mostly made up of virtual and pure virtual methods intended to be overridden by the subclasses.
The difference between a virtual method and a pure virtual method is that the virtual method has a body and it may be overridden by a subclass. If the subclass overrides the method, its version of the method is called.
If the subclass does not override the method, the method of the base class is called instead. A pure virtual method does not usually have a body, and a class holding at least one pure virtual method becomes abstract. The subclass can either override all the pure virtual methods of its base class or become abstract itself:
Draw.h
enum FigureId {LineId, ArrowId, RectangleId, EllipseId}; class DrawDocument; class Draw { public: Draw(const Window* windowPtr);
Each figure has its own identity number, returned by the GetId
method:
virtual FigureId GetId() const = 0...