Template Stack with re size
copy over all the files provided for you
the files are in the usual place
use your main1.cpp from the last homework
For this assignment you will create a template Stack implementation
The stack will be a dynamic design.
The constructor allows the user to pass in a size for the container you can make it any size but it will default to the value of 4.
The stack will automatically double its capacity when full, use your dynamic memory lab as an example where we resized an array.
The steps are
1. use new to allocate a new array 2x the current size
2. copy over the values with a for loop or memcpy
3. delete the old array
4. set your pointer to the new array
you will not use cout or cin ANYWHERE in your stack class.
any cout or cin operations should happen in the main test application
Log the start and end of all functions
the main differnces of this versus the previous stack homework
is that this is a template class and the push function will be modified to resize the internal array as needed
File: Stack.h
#pragma once
#include "cmpslib19.h"
#include "easylogging++.h"
template <class T>
class Stack
{
private:
T * data;
int TopIndex;
int capacity;
// a private function that will double the capacity of the array and copy the values over ... resize
// you will need a constructor it will allow the user to pass in the size/capacity of the container as the only parameter
// have this default to the value of 4
// destructor , clean up the array data
// a public function that returns true or false if the container is empty
// a public function that returns true or false if the container is full
// a public function that allows a value to be added or "pushed" into the stack
// if the container is full it calls resize then adds the value
// returns true
// a public function that will remove or "popp' a value from the stack
// true or false if pop operation was successful
// a public function that returns the value at the top value on the stack
// throws a descriptive message if stack is empty
// a public function that returns the capacity of the stack
// a public function that returns the size of the stack
// ToString returns a string representation of the container.. see example for format
}; // end Stack class
You will complete main1.cpp
do not make your stack of type int or string or fraction , use ELEMTYPE
when you prompt the user to enter a value to insert or search or delete do not use datatype
int, string or fraction, use ELEMTYPE
the make file provided will attempt to create 3 version of you main , one for the 3 datatypes
TESTING YOUR WORK
make sure that your menu driven main works with all the testfiles,but you MUST test this with your own testfiles to make sure it works properly
I WILL TEST THEM WITH SOME VERY LARGE TESTFILES THAT ARE MUCH MORE INVOVLED THAN ANY FO THE ONES PROVIDED FOR YOU YOU WHEN I GRADE THEM