C++ queue 容器
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;//队列 Queueclass Person
{
public:Person(string name, int age){this->m_Name = name;this->m_Age= age;}string m_Name;int m_Age;};int main()
{queue<Person>q;Person p1("小僧", 30);Person p2("悟空", 10000);Person p3("小鼠", 900);Person p4("小萨", 800);q.push(p1);q.push(p2);q.push(p3);q.push(p4);cout << "size()= " << q.size() << endl;while (!q.empty()){cout << "队头->姓名: " << q.front().m_Name << " 年龄: " << q.front().m_Age << endl; cout << "队尾->姓名: " << q.back().m_Name << " 年龄: " << q.back().m_Age << endl;q.pop();}cout << "size()= " << q.size() << endl;return 0;
}