#pragma once #include using namespace std; template class stack { private: //array THING* items; //number of itesm in stack int numItems; //size of array int capacity; void resize(int newCap) { //create new bigger array of size newCap THING* newArr; newArr = new THING[newCap]; //copy items over from old array to new array for (int i = 0; i < numItems; i++) newArr[i] = items[i]; //free the memory of the old array delete[] items; //point item to the new array items = newArr; //update capacity to newCap capacity = newCap; } public: stack() { numItems = 0; capacity = 5; items = new THING[capacity]; } void push(THING x) { if (numItems == capacity) { cout << "Resizing to: " << 2 * capacity << endl; resize(2 * capacity); } items[numItems] = x; numItems++; } THING pop() { numItems--; return items[numItems]; } bool empty() { if (numItems == 0) return true; else return false; } };