Extend the SortedList class you wrote for program #2 by adding:
Also, write a main function to test your new version of the SortedList class. Your main function should demonstrate that adding definitions of the SortedList destructor, copy constructor, and operator= makes a difference. In particular, you should use purify to create two instrumented executables; one version should use the definition of the SortedList class from program 2, and the other should use the new definition of the SortedList class (that includes a destructor, copy constructor, and operator=). Both versions should use your new main function. When the first version is run, purify should give a warning about storage leaks, but there should be no warnings for the second version. Also, either purify should report errors in the first version (but not the second version), or there should be a difference in output between the first and second versions, to demonstrate that including a copy constructor and a definition of operator= in the second version is important.
Note that as described, the two auxiliary functions work only on linked lists, not on SortedLists. So they should be static (private) member functions of the SortedList class. Here's how you would declare them inside the SortedList class declaration:
private: static void FreeList(ListNode *L); static ListNode *CopyList(ListNode *L);When you write the two functions in SortedList.C, do not include the word "static".
Another possibility for CopyList would be to make it a non-static member function of the SortedList class. If S is a SortedList, and L is a pointer to the first node of a linked list, then the call S.CopyList(L) would use recursion to insert the strings in L in right-to-left order into S. (The function would also work if you made it non-recursive, and inserted the strings in L in left-to-right order, but that would be inefficient, because each Insert operation would add a new value to the end of S's list.)
|What to turn-in:||