Question: Stack using array and Templates- C++ Design and implement stack ADT using dynamic array when stk_ptr = size. Class Stack has following functions: Constructor Copy
Stack using array and Templates- C++
Design and implement stack ADT using dynamic array when stk_ptr = size. Class Stack has following functions: Constructor Copy constructor- Initializes the stack to be equivalent to the other Stack object parameter. Destructor- Deallocates (frees) the memory used to store the stack Push- If Stack is not full. Inserts newDataItem onto the top of the stack. Pop- If Stack is not empty. Removes the most recently added (top) data item from the stack and returns the value of the deleted item Isfull- Returns true if the stack is full. Otherwise, returns false. Isempty- Returns true if the stack is empty. Otherwise, returns false. Clear- Removes all the data items in the stack. Print- Outputs the data items in a stack. If the stack is empty, outputs Empty stack. Note that this operation is intended for testing/debugging purposes only. It only supports stack data items that are one of C++'s predefined data types (int, char, and so forth)
Testing: Command Action +x Push data item x onto the top of the stack. - Pop the top data item and output it. E Report whether the stack is empty. F Report whether the stack is full. C Clear the stack. Q Exit the test program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
