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
The answer to the question is available in the PDF file https://www.assignmentexpert.com/https://www.assignmentexpert.com/homework-answers/programming-answer-58336.pdf
Comments
Leave a comment