// CS2310 Exercise 17 // // Name _____________________ SSN ___________________ // // Chapter 16 p960 - 4 // To the SortedList2 class, add a Boolean member function named // Equal that compares two class objects and returns true if the // two lists they represent are identical // // SPECIFICATION FILE DYNAMIC-LINKED Sorted LIST( slist2.h ) typedef int ItemType ; // Type of each component // is simple type or string type struct NodeType { ItemType item ; // Pointer to person’s name NodeType* link ; // link to next node in list } ; typedef NodeType* NodePtr; class SortedList2 { public : bool IsEmpty ( ) const ; void Print ( ) const ; void InsertTop ( /* in */ ItemType item ) ; void DeleteTop ( /* out */ ItemType& item); void Delete ( /* in */ ItemType item ); SortedList2 ( ) ; // Constructor ~SortedList2 ( ) ; // Destructor bool Equal(const SortedList2& otherList); // Precondition: otherList is assigned. // Postcondition: // Compare the list pointed to by head and the // list pointed to by the head member of // otherList. Return true if the two lists are // equally long and the contents of the lists // are exactly the same; false, otherwise. private : NodeType* head; } ;