- To obtain directory containing the starting point for this lab
(essentially the
List class David described), type
cp -r ~mc38/labs/operator-overloading/files list-stuff
After making and running the program, read through the files to the
point that you understand what is going on.
- First add the following member function:
ListItem& operator[](int n);
Note, in particular, that this operator differs from the member
function getNth in that it returns a reference to
the value, not just the value itself. It should also differ by
returning the (n+1)st value; just like arrays, you should begin the
indexing at 0. Add the appropriate code to testList.cc
in order to test that it works properly.
- Add the following
friend function:
ostream& operator<<(ostream&, const List&);
Note that you will need to make it a friend of both Node
and List. Add the appropriate code to
testList.cc in order to test that it works properly.
Check-off: When you have written and tested these procedures,
ask one of us to check you off.