#pragma once class stack { private: //Let's declare some variables double* items; //size of current array int capacity; //number of items currently in the stack int numItems; public: stack() { items = new double[5]; capacity = 5; numItems = 0; } void resize(int newCapacity) { //Step 1: create a new (bigger) array double* otherArray = new double[newCapacity]; //Step 2: copy items over from old array to new array for (int i = 0; i < numItems; i++) { otherArray[i] = items[i]; } //Step 3: update the capacity capacity = newCapacity; //Step 3.5: free the old array memory delete[] items; //Step 4: Set array variable to point at the new (bigger) array items = otherArray; } void push(double x) { //First check if we are out of room if (numItems == capacity) { resize(2 * capacity); } items[numItems] = x; numItems++; } double pop() { double outputItem; outputItem = items[numItems - 1]; numItems--; return outputItem; } //Return true if stack is empty, false otherwise bool empty() { if (numItems == 0) return true; else return false; } //remove all items from stack void clear() { numItems = 0; } };