Question
Language: C++ I need help making an array-based stack header file. In the ABS.h, the default scale factor is 2.0f and when you attempt to
Language: C++
I need help making an array-based stack header file. In the ABS.h, the default scale factor is 2.0f and when you attempt to push() an item onto an ABS that is full, the capacity will get scaled by the scale factor and if the "percent full" (current size/max capacity) becomes less than 1/scalefactor, the capacity should decrease. I need to also create template
The methods that are needed include:
ABS(): Default constructor. Capacity should be initialized to 1, and size should be initialized to 0.
ABS(int capacity): Constructor for an ABS with the specified starting capacity.
ABS(const ABS &d): Copy constructor.
ABS &operator=(const ABS &d): Assignment operator.
~ABS(): Destructor for an ABS.
void push(T data): Add a new item to the top of the stack.
T pop(): Remove the item at the top of the stack, and return its value. Throws -1 if the stack is empty.
T peek(): Return the value of the item at the top of the stack, without removing it. Throws -1 if the stack is empty.
unsigned int getSize(): Returns the current number of items in the ABS.
unsigned int getMaxCapacity(): Returns the current max capacity of the ABS.
T* getData(): Returns the array representing the stack. This should only be used in order to implement the copy constructor or assignment operator.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started