赞
踩
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 &#
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。