# Answer to Question #58336 in C++ for jonney

Question #58336

Take the template class template<class T> class BoundedQueue {

public:virtual ~BoundedQueue() { }

virtual bool isempty() = 0;

virtual bool isfull() = 0;

virtual void put(T& t) = 0; // add t to queue

virtual T get() = 0; // remove element from queue

};

which describes the interface of a bounded queue to which (if the queue is not full) elements

of type T can be added and from which (if the queue is not empty) elements can

be removed (in the order in which they were added). The operations assume that their

preconditions (queue is not full/empty) are satisfied.

Write a concrete template class

template<class T>

class ArrayQueue: public BoundedQueue<T> { ... };

which implements by a constructor

ArrayQueue(int s)

a bounded queue of size s with the help of an array a, a counter n (the number of elements

in the queue) and two indices f (front) and t (tail): elements are added at position t

public:virtual ~BoundedQueue() { }

virtual bool isempty() = 0;

virtual bool isfull() = 0;

virtual void put(T& t) = 0; // add t to queue

virtual T get() = 0; // remove element from queue

};

which describes the interface of a bounded queue to which (if the queue is not full) elements

of type T can be added and from which (if the queue is not empty) elements can

be removed (in the order in which they were added). The operations assume that their

preconditions (queue is not full/empty) are satisfied.

Write a concrete template class

template<class T>

class ArrayQueue: public BoundedQueue<T> { ... };

which implements by a constructor

ArrayQueue(int s)

a bounded queue of size s with the help of an array a, a counter n (the number of elements

in the queue) and two indices f (front) and t (tail): elements are added at position t

Expert's answer

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment