- UID
- 580
- 精华
- 26
- 积分
- 561
- 威望
- 28 点
- 宅币
- 341 个
- 贡献
- 0 次
- 宅之契约
- 0 份
- 最后登录
- 2015-1-29
- 在线时间
- 8 小时
用户组: 大·技术宅
- UID
- 580
- 精华
- 26
- 威望
- 28 点
- 宅币
- 341 个
- 贡献
- 0 次
- 宅之契约
- 0 份
- 在线时间
- 8 小时
- 注册时间
- 2014-12-8
|
C++模板实现的单向队列的元素添加,元素删除,元素清除功能
Queues.hmain.cpp- // main.cpp
- #include <iostream>
- #include "Queues.h"
- using namespace std;
- void main()
- {
- cout<<"*****************************test queue init***************************"<<endl;
- Queues<int> Que;
- cout<<"Queues is empty? :"<<Que.isEmpty()<<endl;
- cout<<"Que's length is:"<<Que.getLength()<<endl;
- cout<<"*****************************test queue add****************************"<<endl;
- Que.add(1);
- Que.add(2);
- Que.add(3);
- Que.add(4);
- Que.print();
- cout<<"Queues is empty? :"<<Que.isEmpty()<<endl;
- cout<<"Que's length is:"<<Que.getLength()<<endl;
- cout<<"*****************************test queue erase**************************"<<endl;
- Que.erase();
- Que.erase();
- Que.print();
- cout<<"Queues is empty? :"<<Que.isEmpty()<<endl;
- cout<<"Que's length is:"<<Que.getLength()<<endl;
- cout<<"*****************************test queue clear**************************"<<endl;
- Que.clear();
- Que.print();
- cout<<"Queues is empty? :"<<Que.isEmpty()<<endl;
- cout<<"Que's length is:"<<Que.getLength()<<endl;
- }
复制代码 程序的运行结果:
|
|