CSc 201/202
Coursework for C/C++ Course
Part 2: Programming with C++
(60% of the C/C++ Coursework
Due Friday Week 1 Lent Term)
The coursework requires you to define and implement a class strList whose instances represent a singly linked list. Each node in the linked list stores a character string. The class should have a public interface as shown below:
strList( ); // a constructor that takes no parameters and
// initialises the various member variables of the
// class
// the big three
~strList( ); // the destructor
strList(const strList&); // the copy constructor
strList& operator=(const strList&); // the assignment operator
// other member functions and overload operators
void put(char*); // creates a new element in the linked list
// to store the string specified as a
// parameter - makes the new element the head
// of the list with the head becoming the next
// element
int find(const char*); // returns 1 if the specified string is
// stored in one of the links of the list,
// returns a 0 otherwise
// the overloaded output operator to display the contents of the
// list
friend ostream& operator<<(ostream&, const strList&);
// a function that serves the same purpose as the output
// operator - just a different way of achieving the same result
void display( );
// overloaded operator+ to concatenate two linked lists
// stores the result in the left hand side linked list (hence
// modifying it) the RHS list is appended to the end of the LHS
// list. The right hand side list remains unchanged
strList& operator+(const strList&);
Note that unlike the linked list exercise for the C part of the course you should store the head of the list in a private member variable of the class.
Write a main function to put your linked list to test. Your program should compile (using g++) and run on unix.
It should also be noted that the source code must be well commented to reflect your understanding of the statements in your program. You can choose to work together. However, acknowledge any such collaboration on your submission.