Question: Implement a template class Stack as defined by the following skeleton template class ItemType> class Staclk private: NodeType ItemType* topPtr; // It points to a






Implement a template class Stack as defined by the following skeleton template class ItemType> class Staclk private: NodeType ItemType* topPtr; // It points to a singly-linked list public Stack(); I/ default constructor: Stack is created and empty Stack(const StackItemType> &); // copy constructor: implicitly called for a // deep copy void MakeEmpty); Stack is made empty; you should deallocate all the // the nodes of the linked list bool IsEmpty); test if the stack is empty bool IsFul1(); // test if the stack is full; assume MAXITEM-5 int length); /return the number of elements in the stack void Print); /print the value of all elements in the stack in the sequence // from the top to bottom void Push(ItemType x); insert x onto the stack void Pop(ItemType &); // delete the top element from the stack // Precondition: the stack is not empty Stack0: // Destructor: memory for nodes needs to be deallocated
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
