Question: stack class Implement template stack class that is capable of storing integer and string values. Write both header and implementation in one file (stack.h) Private

 stack class Implement template stack class that is capable of storinginteger and string values. Write both header and implementation in one file (stack.h) Private data fields: data: An array with maximum size of 20. (Declare a constant in stack.h called MAX_SIZE and set it to 20.)

stack class Implement template stack class that is capable of storing integer and string values. Write both header and implementation in one file (stack.h) Private data fields: data: An array with maximum size of 20. (Declare a constant in stack.h called MAX_SIZE and set it to 20.) size: stores the current number of elements in the stack. Public interface: stack0: constructs an empty stack. push(T val): inserts a new element (val) of type T (T could be integer or string) into the data. If the data array is full, this function should throw an overflow_error exception with error message "Called push on full stack." pop0: removes the last element from data. If the data array is empty, this function should throw an outofrange exception with error message "Called pop on empty stack. top0: returns the top element of stack (last inserted element). If stack is empty, this function should throw an underflow_error exception with error message "Called top on empty stack.. empty0: returns true if the stack is empty otherwise it returns false. main.cpp test harness Use this main.cpp file for testing your stack Use this main.cpp file for testing your stack. #include #include #include #include "stack"h" > test; cout stack1 ; if (stackl.empty)) cout stack2; cout stack3; cout stack4; cout stack5 cout

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!