#include<iostream> template <class T> class Queue { private: T rear; T front; int maxSize; T* head; public: Queue(int size):rear(0),front(0),maxSize(size) { head = new T(size); if(!head) std::cout << "memoryAllocationError!" << std::endl; } ~Queue() { maxSize = 0; delete[] head; } bool IsEmpty() { return front == rear; } bool IsFull() { return rear - front == maxSize; } void inQueue(T item) { if(IsFull()) std::cout << "Queue is full!" << std::endl; *(head + rear) = item; rear ++; } T outQueue() { if(IsEmpty()) std::cout << "Queue is empty!" << std::endl; T item = *(head + front); front ++; return item; } void Destroy() { ~Queue(); } };