// CS2310 Exercise 15 // Chapter 16 // // Name ____________________________ SSN _____________________ // // p960 - 1 // To the SortedList2 class, add a value-returning // member function named Length that counts and returns // the number of nodes in a list. // // 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 ) ; int Length(void); // POST: Return the number of elements in // the list. SortedList2 ( ) ; // Constructor ~SortedList2 ( ) ; // Destructor private : NodeType* head; } ;