Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

57 Occupational injury and illness compensation and programs.

Answered: 1 week ago

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago