Question: Given the definition of the class TList below, please write the code for its member functions. The description of each function is included This is

Given the definition of the class TList below, please write the code for its member functions. The description of each function is included

This is a coding assignment where, after being given starter code on a Linked List, we have to write the implementation of several different functions

node.h template class Node { friend class TList; friend class TListIterator; public: Node(const T& d); Node(T && d); private: T data; // data element to store of type T Node * prev; // pointer to previous node Node * next; // pointer to next node };

TList.h

template 
 class TList { friend class TListIterator; public:  TList(); // Create empty linked list**** TList(T val, int num); // Create list with num copies of val**** ~TList(); // Destructor**** TList(const TList& L); // Copy constructor**** bool IsEmpty() const; // Checks to see whether list is empty**** void Clear(); // Clear out list, reset to empty**** int GetSize() const; // Return the size of the list**** void InsertFront(const T& d); // Insert data d as first element**** void InsertBack(const T& d); // Insert data d as last element**** void RemoveFront(); // Remove first element of list**** void RemoveBack(); // Remove last element of list**** T& GetFirst() const; // Return first element of list**** T& GetLast() const; // Return last element of list**** TListIterator GetIterator() const; // Return iterator to first item**** TListIterator GetIteratorEnd() const; // Return iterator to last item**** // ********************************************************** // * Insert data element d just before item at pos position * // ********************************************************** void Insert(TListIterator pos, const T& d);**** // ********************************************************** // * Remove data item at position pos. Return iterator * // * to the item. * // * that comes after the one being deleted. * // ********************************************************** TListIterator Remove(TListIterator pos);**** // ********************************************************** // * Print list contents in order, separated by given * // * delimiter. * // ********************************************************** void Print(std::ostream& os, char delim = ' ') const;****  private: Node* first; // pointer to first node in list Node* last; // pointer to last node in list int size; // number of nodes in the list static T dummy; // dummy object, for empty list data returns // assuming type T has default construction };

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!