|
|
|
|
|
|
|
to insert the TimeCard class declaration into the program, and we use
|
|
|
|
|
|
|
|
|
to insert the TimeCardList class declaration. (Recall that tclist.h also happens to #include the header file timecard.h. Thus, timecard.h gets inserted into our program twice. If we had not used the #ifndef directive at the beginning of timecard.h, we would now get a compile-time error for declaring the TimeCard class twice.) |
|
|
|
|
|
|
|
|
To run the program, we link its object code file with the object code files tclist.obj, timecard.obj, and time.obj. |
|
|
|
|
|
|
|
|
//******************************************************************
// PunchIn program
// A data file contains time cards for employees who have punched
// in for work. This program reads in the time cards from the
// input file, then reads employee ID numbers from the standard
// input. For each ID number, the program looks up the employee's
// punch-in time and displays it to the user
//******************************************************************
#include bool.h
#include timecard.h // For TimeCard class
#include tclist.h // For TimeCardList class
#include <iostream.h>
#include <fstream.h> // For file I/O
void GetID( long& );
void OpenForInput( ifstream& );
int main()
{
if stream punchInFile; // Input file of time cards
TimeCardList punchInList; // List of time cards
TimeCard punchInCard; // A single time card
long idNum; // Employee ID number
Boolean found; // True if idNum found in list
OpenForInput(punchInFile);
if ( !punchInFile )
return 1;
punchInList.ReadAll(punchInFile);
punchInList.SelSort();
|
|
|
|
|
|