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

}

相关推荐
繁星星繁2 小时前
【项目】基于SDK实现的智能聊天助手(使用api接入deepseek)------(二)
c++·设计模式·学习方法
CSDN_RTKLIB2 小时前
【类定义系列三】内联函数进阶
开发语言·c++
北京流年2 小时前
执行clang --version报错说由于找不到 libgcc_s_seh-1.dll和 找不到 libstdc++-6.dll 这两个文件
开发语言·c++
weixin_440730502 小时前
Java基础学习day01
java·开发语言·学习
军军君013 小时前
Three.js基础功能学习一:环境资源及基础知识
开发语言·javascript·学习·3d·前端框架·threejs·三维
是垚不是土3 小时前
基于DDNS-Go动态域名解析配置:实现多网络线路冗余切换方案
运维·开发语言·网络·阿里云·golang·运维开发
@大迁世界3 小时前
JavaScript 框架的终结
开发语言·前端·javascript·ecmascript
catchadmin3 小时前
PHP True Async 最近进展以及背后的争议
开发语言·php
fpcc3 小时前
跟我学C++中级篇—Linux内核中链表分析
linux·c++·链表