In the following procedure you’ll implement the NewStroke function that you declared earlier. NewStroke manages the stroke data in Scribble’s drawings.
To implement document members for managing Scribble’s data
NewStroke (in class CScribbleDoc), and fill it in with the following code:CStroke* pStrokeItem = new CStroke(m_nPenWidth);
m_strokeList.AddTail( pStrokeItem );
SetModifiedFlag( ); // Mark document as modified
// to confirm File Close.
return pStrokeItem;
Note The new operator never returns NULL. Instead, an exception is thrown if memory could not be allocated. This would be a good place to implement an exception handler with the TRY and CATCH macros.
In the above code, NewStroke:
CStroke object dynamically using the C++ new operatorCStroke object with the current pen width