64,676
社区成员
发帖
与我相关
我的任务
分享
#ifndef Queue_h
#define Queue_h
template<typename Type> class Queueitem
{
template<typename T> friend class Queue1;
Queueitem(Type q) :item(q), next(0){}
Type item;
Queueitem *next;
};
template<typename T> class Queue1
{
public:
Queue1() :head(0), tail(0){}
Queue1(const Queue1& q) :head(0), tail(0)
{
copy_elem(q);
}
Queue1& operator=(const Queue1& q);
T& front();
void push(const T& val);
void pop();
bool empty()
{
return head == 0;
}
~Queue1()
{
destory();
}
private:
Queueitem<Type> *head;
Queueitem<Type> *tail;
void copy_elem(const Queue1 &q);
void destory();
};
#include"Queue.cpp"
#endif