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

}

相关推荐
徐某人..19 小时前
基于i.MX6ULL平台的智能网关系统开发
arm开发·c++·单片机·qt·物联网·学习·arm
无敌秋20 小时前
# C++ 简单工厂模式实战指南
c++·简单工厂模式
淘矿人20 小时前
从0到1:用Claude启动你的第一个项目
开发语言·人工智能·git·python·github·php·pygame
cany100020 小时前
C++ -- 模板的声明和定义
开发语言·c++
澈20720 小时前
深耕进阶 Day1:C 与 C++ 核心差异 + C++ 入门基石
c语言·开发语言·c++
Felven20 小时前
C. Need More Arrays
c语言·开发语言
love530love20 小时前
Podman Machine 虚拟硬盘迁移实战二:用 Junction 把 vhdx 从 C 盘搬到其他盘
c语言·开发语言·人工智能·windows·wsl·podman·podman machine
脱氧核糖核酸__20 小时前
LeetCode热题100——234.回文链表(两种解法)
c++·算法·leetcode·链表
愚者游世21 小时前
noexcept 说明符与 noexcept运算符各版本异同
开发语言·c++·程序人生·面试·visual studio