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 ArrowFigure Class


Arrow Figure is a direct sub class of Figure and it inherits LineFigure privately, and reuses most of the functionality. Similar to LineFigure, it draws a line, and then adds the extension of two extra lines that constitutes an arrowhead. The class has two fields of its own, m_ptLeft and m_ptRight, which holds the end points of the arrowhead. It also reuses the fields m_ptFirst and m_ptLast of LineFigure. Moreover, it has a constant ARROW_LENGTH; it is initialized to 500, which means that the extra lines constituting the arrowhead are five millimeters long, regardless of the length of the arrow itself.

The constructors just call the corresponding constructors in their base class LineFigure. GetArea calculates the area of the arrow by calling its analogous function in LineFigure. In addition to that, it also calculates the area of the arrowhead. The resulting area is the smallest rectangle containing the whole arrow.

Copy creates and returns a pointer to an identical...