//Queue #include using namespace std; template class Queue { public: Queue (int m); ~Queue (); void Enqueue (x e); void Dequeue (x& e); int QueueIsFull (); int QueueIsEmpty (); void QueueRetreive (x& e); private: int maxsize; x *p; int rear; int front; }; int main() { Queue q(20); int i; q.Enqueue(1); q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); q.Enqueue(5); q.Enqueue(8); q.Dequeue(i); cout << i << endl; q.Dequeue(i); cout << i << endl; q.Dequeue(i); cout << i << endl; return 0; } template Queue::Queue(int m) { maxsize = m; p = new x[maxsize]; rear = -1; front = -1; } template Queue::~Queue() { delete [] p; rear = front = -1; } template int Queue::QueueIsFull() { if (rear == maxsize - 1) return 1; return 0; } template int Queue::QueueIsEmpty() { if (rear == front) return 1; return 0; } template void Queue::Enqueue(x e) { if(!QueueIsFull()){ rear++; p[rear] = e; } } template void Queue::Dequeue(x& e) { if(!QueueIsEmpty()){ front++; e = p[front]; } } template void Queue::QueueRetreive(x& e){ if(!QueueIsEmpty()){ front++; e = p[front]; front--; } }