< previous page page_1005 next page >

Page 1005
1005-01.gif
Figure 17-15
ptrList Array Before and After Sorting
three operations: read all the records into the list, sort the list, and print all the records in the list. Because our data representation uses dynamically allocated data, we must consider supplying additional operations: a class constructor, a class destructor, a class copy-constructor, and a deep copy operation. At a minimum, we need a constructor to initialize the private data and a destructor to deallocate all the PersonnelData variables from the free store. (Case Study Follow-Up Exercise 3 asks you to write the copyconstructor and deep copy operations.)
Below is the specification of the RecordList class. Notice that we use a Typedef statement to define the identifier PersonPtr as a synonym for the type PersonnelData*. Thereafter, we can declare the ptrList array as
PersonPtr ptrList[MAX_EMPL];
instead of
PersonnelData* ptrList[MAX_EMPL];

//******************************************************************
// SPECIFICATION FILE (reclist.h)
// This file gives the specification of RecordList, an ADT for a
// list of personnel records.
//******************************************************************

 
< previous page page_1005 next page >