- 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.
- Though it should not be a problem in writing this program, be aware of
the possibility of corruption of data when re-using a "buffer" - for example,
in the following code segment taken from "buildLists:"
for (clientNum=1; 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" there is no possibility that data remaining in "item"
from its previous use will "contaminate" the new set of data being copied into
"item." In this program, since the number of interests is a variable, it is
possible that interests of the previous client would remain in "item" after
the interests of the next client are copied in. If the numIntrs field is
always used correctlty throughout the program, no problems will result from
the fact that there are "bogus interests" in "item" - past where the interest
list logically ends.
- 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.