#include
using namespace std;
const int Max=100;
template
class MyQueue
{
private:
T *aa;
unsigned int front;
unsigned int tail;
public :
void init();
bool isEmpty();
T DeQueue();
void EnQueue(const T a);
unsigned int size();
void destroy();
};
template
void MyQueue::init()
{
aa = new T[Max+1];
front=0;
tail=0;
return;
};
template
bool MyQueue::isEmpty()
{
if(front==tail-1) return true;
else return false;
};
template
unsigned int MyQueue::size()
{
return tail-front;
};
template
void MyQueue::EnQueue(const T a)
{
tail=tail+1;
aa[tail]=a;
};
template
T MyQueue::DeQueue()
{
front=front+1;
T t=aa[front];
cout << t << endl;
return t;
};
template
void MyQueue::destroy()
{
delete[] aa;
};
int main()
{
MyQueue st;
st.init();
if(st.isEmpty()) cout << "MyQueue is empty." << endl;
else cout <<"MyQueue is not empty." << endl;
st.EnQueue('a');
st.EnQueue('b');
st.EnQueue('c');
st.DeQueue();
cout << st.size() << endl;
st.EnQueue('d');
st.EnQueue('e');
st.EnQueue('f');
cout<< st.size()< while(!st.isEmpty()) st.DeQueue();
st.destroy();
system("pause");
return 0;
}