c++ 容器 queue

#include <iostream>

#include <string>

#include <fstream>

#include <vector>

#include <algorithm>

#include <deque>

#include <stack>

#include <queue>

using namespace std;

class Preson

{

public:

Preson(string name,int age)

{

this->name = name;

this->age = age;

}

string name;

int age;

};

void test01()

{

queue<Preson> q;

Preson p1("Alice", 25);

Preson p2("Bob", 30);

Preson p3("Charlie", 35);

q.push(p1);

q.push(p2);

q.push(p3);

cout << "size:" << q.size() << endl;

while (!q.empty())

{

cout << "name:" << q.front().name << " age:" << q.front().age << endl;

cout << "name:" << q.back().name << " age:" << q.back().age << endl;

q.pop();

}

cout << "size:" << q.size() << endl;

}

int main()

{

test01();

return 0;

system("pause");

}

相关推荐
小小龙学IT1 分钟前
libuv 开源异步 I/O 事件循环库深度解析:Node.js 的心脏,C++ 高性能网络程序的引擎
c++·开源·node.js
彷徨而立9 分钟前
【C/C++】多线程读写普通 int 变量的一些问题(二)
c语言·c++
一只旭宝12 分钟前
五种线程池设计
c++·笔记
luj_176816 分钟前
毒素驱动的生物自毁机制探析
服务器·c语言·开发语言·经验分享·算法
某林21219 分钟前
机器人收不住、转不动?执行器死区的原理与三层补偿设计
前端·网络·c++·架构·机器人
海兰25 分钟前
【 Python 量化交易】第6章:数据可视化
开发语言·python·信息可视化
多多鼠25 分钟前
Tool Calling的信任边界:从协议校验到执行沙箱的完整链路设计
运维·开发语言·网络·人工智能·python·langchain
啊阿狸不会拉杆29 分钟前
《计算机网络-自顶向下方法》1.5 协议层次及其服务模型 读书笔记
开发语言·计算机网络·php
tryxr35 分钟前
Chat2Excel 项目通用服务开发
java·开发语言·excel·java项目开发
Jazz_z42 分钟前
使用 Python 合并与取消合并 Excel 单元格
开发语言·python·excel