Question: A stack is an Abstract Data Type (ADT) that implements a data structure with last-in, rst-out (LIFO) behavior. Common operations on a stack include push,

A stack is an Abstract Data Type (ADT) that implements a data structure with last-in, rst-out (LIFO) behavior. Common operations on a stack include push, pop, top, isEmpty and isFull. This part of your programming assignment focuses upon building and using a implementation of stacks. AStack the implementation of stack will use an array whose bounds are xed at creation time. Implementing this program should be trivial now that you have implemented the Array class. Your task is to write C++ methods that operate upon objects of class AStack.

#include

#include "AStack.h"

template AStack :: AStack (size_t size = INITIAL_STACK_SIZE) { /* Your code here */ }

template AStack :: AStack (const AStack& s) { /* Your code here */ }

template AStack& AStack :: operator= (const AStack& s) { /* Your code here */ }

template AStack :: ~AStack (void) { /* Your code here */ }

template void AStack :: push (const T& new_item) { /* Your code here */ }

template void AStack :: pop (T& item) { /* Your code here */ }

template void AStack :: top (T& item) { /* Your code here */ }

template bool AStack :: is_empty (void) const { /* Your code here */ }

template bool AStack :: operator == (const AStack& s) const { /* Your code here */ }

template bool AStack :: operator != (const AStack& s) const { /* Your code here */ }

template bool AStack :: overflow(void) { /* Your code here */ }

template bool AStack :: underflow(void) { /* Your code here */ }

Note that pop() and top() methods explicitly check whether the stack is empty using the is empty() method. The push() method uses the Array::set() method, which grows the array as necessary. Other thing you should know: You are allowed to use Visual Studio, a GNU C++ compiler or an equivalently strict C++ compiler. The standard of C++ is C++98 or C++11.

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!