Question: For this practice assignment you will be writing simple array based stacks and queues. Your classes should be templated and they should inherit from the

For this practice assignment you will be writing simple array based stacks and queues. Your classes should be templated and they should inherit from the following virtual base classes. Note that for templated classes, the methods have to be put in the header files, not in a separate source file. Your classes should be called ArrayStack and ArrayQueue and they should be in files called ArrayStack.h and ArrayQueue.h.

template

class Stack {

public:

virtual ~Stack() {}

virtual void push(const T &t) = 0;

virtual T pop() = 0;

virtual T peek() const = 0;

virtual bool isEmpty() const = 0;

};

template

class Queue {

public:

virtual ~Queue() {}

virtual void enqueue(const T &t) = 0;

virtual T dequeue() = 0;

virtual T peek() const = 0;

virtual bool isEmpty() const = 0;

};

Make sure that your classes have appropriate copy constructors and assignment operators. These can work with the ArrayStack and ArrayQueue types and not the supertypes to keep things simple for you. For performance reasons you might consider implementing a move methods, but that isn't required to pass the test code. You are not allowed to use any of the standard collections for this assignment. So no vector, deque, list, etc.

free memory appropriately!!!

Can someone explain where I should start on this assignment. I find it somewhat daunting. It would be helpful if someone could disect and explain the starter code and then show me what my code should look like --maybe focusing just on stack so that way I can practice with a queue.

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!