#include <stdio.h>
template <class T>
class arrQueue
{
private:
int maxSize;
int front, rear;
T *queue;
public:
//构造函数
arrQueue()
{
maxSize=2;
queue=new T[maxSize];
front=rear=0;
}
//入队列
bool in(T value)
{
if(queue==NULL)
{
printf("顺序队不存在!\n");
return false;
}
if((rear+1)%maxSize==front)
{
T *q;
q=new T[maxSize];
int i;
for(i=0; i<maxSize; i++) q[i]=queue[i];
delete[] queue;
queue=new T[maxSize+10];
for(i=0; i<maxSize; i++) queue[i]=q[i];
maxSize=maxSize+10;
delete[] q;
}
queue[rear]=value;
rear=(rear+1)%maxSize;
return true;
}
}