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.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!