< previous page page_1009 next page >

Page 1009
ues are in order. The location in this algorithm that we must change is where the minimum value is determined. Instead of comparing two components in the list, we compare the last name members in the structs to which these components point. The statement that did the comparison in the original SelSort function must be changed from
if (list[placeCount] < list[minIndex])
to
if (strcmp(ptrList[placeCount]->lastName,
           ptrList[minIndex]->lastName) < 0)
The remaining member functionsPrintAll and the class destructorare straightforward to implement.
PrintAll ()
FOR index going from 0 through length -1
  Print ptrList[index]->lastName, , , ptrList[index]->firstName
  Print ptrList[index]->address.street
  Print ptrList[index]->address.city, , , ptrList[index]->address.state
  Print ptrList[index]->workHistory
  Print ptrList[index]->education
  Print ptrList[index]->payrollData

The class destructor ~RecordList ()
FOR index going from 0 through length -1
  Deallocate the struct pointed to by ptrList[index]

Below is the implementation file for the RecordList class. In the code, there are two C++ issues you should observe. First, GetRecord is a helper functiona function that is not a member of the class but is physically located in the implementation file to help a member function accomplish its task. Because GetRecord is not a class member, its name is not preceded by RecordList:: as are the names of the other functions. Second, the input description for this case study says that the input strings (last name, first name, street address, and so on) can contain embedded blanks. Therefore, in

 
< previous page page_1009 next page >