To add implementation code for the CStroke members
CStroke
’s two empty constructors to ScribbleDoc.cpp, after the last line of CScribbleDoc
code:
Tip Jump to ScribbleDoc.cpp by selecting CScribbleDoc
from the Class combo box in WizardBar. Click the action button on the right side of WizardBar. The action button’s default opens the .cpp file and highlights the line for the displayed member function’s definition.
////////////////////////////
// CStroke
CStroke::CStroke()
{
// This empty constructor should be used by
// the application framework for serialization only
}
CStroke::CStroke(UINT nPenWidth)
{
m_nPenWidth = nPenWidth;
}
The first constructor, declared protected in ScribbleDoc.h, is used only by the application framework during serialization of CStroke
objects. Its parameter list and function body are empty. The second constructor is for public use, to construct new stroke objects directly. When it constructs a new stroke object, the public constructor initializes the pen width. CStroke
doesn’t declare its own destructor — it relies on CObject to provide one by default.
At this point, class CStroke
is not quite complete. You’ll add code for the remaining member function, DrawStroke
, in Redrawing the View, later in Lesson 4.