#include <iostream>
using namespace std;
int poporder = 0;
class node
{
friend class Queue;
private:
long data;
node * next;
};
class Queue
{
public:
Queue();
~Queue();
void destroy();
bool push(long item);
bool pop();
private:
node *rear;
node *front;
int Queuelenth;
};
Queue::Queue()
{
rear = new node;
rear->next = NULL;
front = rear;
Queuelenth = 0;
}
Queue::~Queue()
{
destroy();
delete rear;
delete front;
}
void Queue::destroy()
{
for(int i = 0;i < Queuelenth; i++ )
{
pop();
}
}
/********入队列*******/
bool Queue::push(long item)
{
node *newnodep = new node;
newnodep->data = item;
rear->next = newnodep;
rear = newnodep;
Queuelenth++;
return true;
}
/******出队列********/
bool Queue::pop()
{
if(Queuelenth == 0)
return false;
node *popnodep = front->next;
front = front->next;
Queuelenth--;
return true;
}