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

}

相关推荐
Joy T5 小时前
Agent 确定性上下文设计:从 Prompt 参数注入到能力分层
java·开发语言·微服务·架构·prompt·agent context
专注仿真8 小时前
引擎扩展性与集成设计深度剖析:从 14 个扩展点到 DIS→HLA 演进之路
开发语言·算法·仿真引擎·推演引擎
Best-Wishes9 小时前
科来网络分析系统(技术交流版)使用说明书
开发语言·junit·php
代码不停9 小时前
自动化测试(java)
java·开发语言·selenium·自动化
别动我齐刘海10 小时前
Linux 系统调试学习1
linux·运维·服务器·c++·学习·机器学习·机器人
鬼手点金11 小时前
opencode-rules 插件
java·开发语言·前端·人工智能·chrome·git·github
爱上网的小舟11 小时前
星际战士2启动错误怎么办?5种游戏报错解决方法
开发语言·php
阿里嘎多学长12 小时前
2026-10-12 GitHub 热点项目精选
开发语言·程序员·github·代码托管
wangchunyu11413 小时前
Python 数据可视化实战入门教程
开发语言·python·信息可视化
学逆向的14 小时前
C 突破编译器限制
c语言·开发语言·网络安全