Corrections, clarifications, and other announcements regarding this programming assignment will be found below.
In programming assignment 2 the issues of proper memory management for the Student and SortedList classes were ignored. The compiler defaults for the destructors, copy constructors, and copy assignment operators were assumed to be good enough. For this assignment you'll write your own to ensure that memory dynamically allocated in the classes is correctly managed.
The goals of this assignment are to gain experience:
Add the following to the Student class you wrote for Programming Assignment 2:
Make sure to modify both Student.h and Student.cpp.
Add the following to the SortedList class you wrote for Programming Assignment 2:
Make sure to modify both SortedList.h and SortedList.cpp.
Both the destructor and copy assignment operator of the SortedList class must deallocate the nodes of a linked list returning them to the free storage (i.e., the heap). Both the copy constructor and copy assignment operator make a deep copy of an existing linked list. Therefore, we expect you to write two auxiliary (helper) functions to handle these two tasks.
private: void freeList (ListNode* L); ListNode* copyList (ListNode* L);
Implement an auxilliary function, named freeList, having one parameter, a pointer to a ListNode. This function traverses the linked list, returning each node to free storage. We expect it to be used by both the destructor and copy assignment operator.
Also implement an auxilliary function, named copyList, having one parameter, a pointer to a ListNode. This function returns a pointer to the first node of a copy of original linked list. We expect it to be used by both the copy constructor and the copy assignment operator.
Note both auxilliary functions are implemented as private and intended to only be used within the class.
You can assume that your program will be tested on a main.cpp function that is similar to this one. We are not providing sample output in order to give you practice in reading the code and determining what you think the proper output should be.
Make sure your code follows the style and commenting standards used in CS 302 and CS 367. Note: the commenting standards use javadoc comments for class, method, and constructor headers. You do not need to use javadoc comments in your c++ programs for CS 368; however, your comments should include the same information as the javadoc comments. For example, your function header comments should include a description of what the function does, the name and a short description of each parameter, and a description of the return value.
Electronically submit the following file to your in "handin" directory by the due date and time (or refer to the late policy):
Please turn in only the files named above. Extra files clutter up the "handin" directories.
© 2012-2014 CS368 Instructors