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 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
