OOPortal OOPortal

ATL Development   «Prev  Next»
Lesson 14 Adding application data
Objective Add phone record management data to CPhBookObj.
In this lesson, we will add internal member variables and methods to CPhBookObj to support storing and managing PhRec structures.
The first step is to add a constant for the maximum number of phone records. Open PhBookObj.h and add #define MAX_RECS 32 after #include resource.h.
After we've added the constant for the maximum number of phone records, we have to:
  1. Add an array of PhRecs to CPhBookObj
  2. Add a member variable, m_numrecs, to hold the number of records currently stored in m_PhRecs
  3. Add member variable m_currec to hold the value of the CurRec property; a value of -1 indicates that CurRec is not set

Add Internal Member Variables
Finally, once we have added the member variables, we have to initialize m_numrecs and m_currec in the constructor of CPhBookObj in PhBookObj.h.
CPhBookObj() : m_numrecs(0), m_currec(-1)
Changes to CPhBookObj are reflected in PhBookObj.h.

Adding Application Data - Exercise

Click the Exercise link below to apply what you have learned about adding and initializing member variables.
Adding Application Data - Exercise