Book Image

Microsoft Visual C++ Windows Applications by Example

By : Stefan Bjornander, Stefan Björnander
Book Image

Microsoft Visual C++ Windows Applications by Example

By: Stefan Bjornander, Stefan Björnander

Overview of this book

Table of Contents (15 chapters)
Microsoft Visual C++ Windows Applications by Example
Credits
About the Author
About the Reviewer
Preface
Index

The TwoDimensionalFigure Class


TwoDimensionalFigure is a sub class of Figure and the base class of RectangleFigure and EllipseFigure. A two-dimensional figure can be filled or unfilled. TwoDimensionalFigure has the field m_bFilled with their methods Fill and IsFilled to keep track of the fill status.

TwoDimensionalFigure.h

class TwoDimensionalFigure : public Figure
{
  public:
    TwoDimensionalFigure();
    TwoDimensionalFigure(const Color& color, BOOL bFilled);

    BOOL IsFilled() const {return m_bFilled;}
    void Fill(const BOOL bFill) {m_bFilled = bFill;}
    void Serialize(CArchive& archive);

  private:
    BOOL m_bFilled;
};

The implementation of Figure is rather straightforward. Remember that each time we introduce a new class to the application we have to include the header file StdAfx.h at the beginning of the implementation file. Otherwise, the application will not work.

TwoDimensionalFigure.cpp

#include "StdAfx.h"

#include "..\\List.h"
#include "..\\Color.h"
#include ...