queue类为容器适配器,它给予程序员队列的功能,存储数据特性为先进先出。
类的定义
template <typename T>
class MyQueue
{
private:
T *first;
T *last;
int len;
public:
函数代码
}
类中包含四大基本函数——析构函数、构造函数、拷贝构造函数、拷贝赋值函数
析构函数
MyQueue()
{
first = new T[1];
last = first; //说明为空
len = 0;
}
构造函数
~MyQueue()
{
delete []first;
first = last = NULL;
}
拷贝构造函数
MyQueue(const MyQueue &other)
{
this->len = other.len;
this->first = new T[other.len+1];
memcpy(this->first,other.first,other.len*sizeof (T));
}
拷贝赋值函数
MyQueue &operator=(const MyQueue &other)
{
int size &#