(Latest Revision -- 03/26/2009)

Examples of the Types of Statements That Could Be Used in the Match Maker Program



// Allow the use of words MALE and FEMALE to index the list array.
const int MALE = 0 ;
const int FEMALE = 1 ;

// Open file "clients" & bind to internal ifstream variable clientFile.
ifstream clientFile ("clients") ;
// Abort with error message if the statement above failed.
assert (clientFile) ;
// Read something from the clientFile stream.
// (It reads from the file "clients" in the computer's file system.)
clientFile >> numClients ;
// Close a file.
clientFile.close() ;

// Declare a variable for client data.
clientRecType record ;

// Read something from a stream into a field of a variable of clientRecType.
clientFile >> record.lastName ;
// Read an interest string into a suitable location.
// "idx" is an int variable used as an array index.
clientFile >> record.interest[idx] ;
// Output something stored in a clientRecType variable.
cout << "processing interest: " << record.interest[idx] << endl ;

// Find out how many elements are in one of the lists.
int posInList = clientLists[index].getLength()
// Insert an element into one of the lists - at the end of the list.
// (This assumes the program has already placed all the required 
// information into the variable of clientRecType called record 
// - the last and first names, phone number, and so on.)
int posInList = clientLists[index].getLength()+1
bool success ;
clientLists[index].insert(posInList, record, success) ;
assert(success);

// Retrieve a record from location "pos" in a (single) list named clientList.
clientRecType record ;
bool success ;
clientList.retrieve(pos, record, success) ;
assert (success) ;