- You need to put #include<fstream> in the program in order
to use objects of type ifstream and ofstream (input and output files).
I have this "syntactic sugar" at the beginning of my program:
#include <fstream>
#include "ListA.h"
#include <string>
/* Define the client record data type */
#include "clientRec.h"
using namespace std ;
- You must pass a stream as a reference parameter.
- An array (e.g. an array of lists) is passed by reference
automatically. (The name of an array is equivalent to a const
pointer to the base of the first array slot.)
- HOWEVER individual objects of one of the list classes will
NOT be passed by reference automatically so it is necessary to
use the &.
- Unlike the indexing of C++ arrays, the list elements are (logically)
numbered from 1 up to the size (length). There is no 0-th element of a list,
Generally, a list with N elements has an Nth element.
Example: If the list contains 10 elements, they are in
positions 1 through 10.
Example: You will want to have some for-loops that look like this:
for (i=1; i<=numberWomen; i++)
rather than like this:
for (i=0; i<numberWomen; i++)
Be careful, it is easy to forget to change one or both of the
upper or lower index limits of the loop.
- There has to be some way to look at the client record and
determine if the record is matched or not. Use the special value
0 (zero) in the matched position field to denote that there is no
current match.
- Your program should close streams (files) after it finishes
using them. If not, it may have problems opening other files.
- Be careful to clear "buffers" appropriately before loading
the next set of data. For example, in the following code
segment taken from "buildLists:"
for (clientNum=0; clientNum<numClients; clientNum++)
{
getNextClient(item, gender, clientFile) ;
putClientInList(item, gender, clientD) ;
}
The function "getNextClient" has to somehow make sure that when
it puts new information into "item" that no old information
remains from the previous client record. This is particularly
apt to occur in the list of interests if not handled correctly.
- Remember to indent your code properly, put a header comment at the
beginning of each function, and turn in a test script showing adequate
testing. I will take off significant numbers of points if you neglect these
things.