Lecture 35
files in ./
problems.cpp demonstrates some problems that one might encounter
when dealing with pointers to objects.
files in ./linkedlistbad
The following code mimics the linked list implementation from last week's lab.
The implementation has several problems, including creating shallow copies when
either the copy constructor or operator= function are called, and memory leaks
associated with the clear and removeFirst member functions of
the LinkedList class.
files in ./linkedlistimproved
The following code corrects the shallow copy problem of the above code by rewriting
the copy constructor and operator= member functions of the LinkedList class so that
they walk the list and copy each node. It also corrects the memory leaks in the clear
and removeFirst member functions by deleting the nodes as they are removed.