#include<iostream> using namespace std; class Queue { int data[10]; int head; int tail; public: Queue(); void Enqueue(int dat); int Dequque(); }; Queue::Queue() { head = tail = 0; } void Queue::Enqueue(int dat) { int len = sizeof data / data[0]; if (tail == len - 1) tail = 0; if (tail + 1 == head) { cout << "overflow"<<endl; return; } data[tail++] = dat; } int Queue::Dequque() { int len = sizeof data / sizeof data[0]; if (head == len - 1) head = 0; if (head == tail) { cout << "NULL" << endl; return -1; } return data[head++]; } int main() { Queue q; q.Enqueue(1); q.Enqueue(2); cout<<q.Dequque()<<endl; cout << q.Dequque()<<endl; cout << q.Dequque()<<endl; return 0; }