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");

}

相关推荐
2401_8920709819 小时前
【Linux C++ 日志系统实战】LogFile 日志文件管理核心:滚动策略、线程安全与方法全解析
linux·c++·日志系统·日志滚动
yuzhuanhei20 小时前
Visual Studio 配置C++opencv
c++·学习·visual studio
Wenweno0o20 小时前
0基础Go语言Eino框架智能体实战-chatModel
开发语言·后端·golang
chenjingming66620 小时前
jmeter线程组设置以及串行和并行设置
java·开发语言·jmeter
cch891820 小时前
Python主流框架全解析
开发语言·python
不爱吃炸鸡柳20 小时前
C++ STL list 超详细解析:从接口使用到模拟实现
开发语言·c++·list
十五年专注C++开发20 小时前
RTTR: 一款MIT 协议开源的 C++ 运行时反射库
开发语言·c++·反射
Momentary_SixthSense20 小时前
设计模式之工厂模式
java·开发语言·设计模式
‎ദ്ദിᵔ.˛.ᵔ₎21 小时前
STL 栈 队列
开发语言·c++
勿忘,瞬间21 小时前
数据结构—顺序表
java·开发语言