HW13: Linked List

  1. Consider the class definition of CList, which stores a linked list.
  2. Inspect the construction, and make sure you understand how it initialize a linked list.
  3. Combine it with main.cpp and try to compile. The Print() function will display the value of nodes in the list sequentially.
  4. Inspect the push_front() function, which inserts a new node in front of the list.
  5. Try to design a push_back() function, which appends a new node at the end of the list.
  6. Furthermore, overload the >> operator so that you can print out the list with a statement like cout << myList;
    Remember that you must declare the >> operator as a friend function of your CList class.
  7. Test your class with the following main() function.
    int main()
    {
      CList a(3);
      a.push_front(5);
      a.push_front(7);
      a.push_back(1);
      a.Print();
      cout << a;
      return 0;
    }
    
  8. Submit the class definition file with filename "hw13-your_stu_id-list.h"