queue队列容器
1.1queue基本概念



1.2queue常用接口

#include"pch.h"
#include<iostream>
#include<string>
#include<opencv2/opencv.hpp>
#include<vector>
#include<algorithm>
using namespace std;
using namespace cv;
class Person
{
public:
Person(string name, int age)
{
this->m_Name = name;
this->m_age = age;
}
string m_Name;
int m_age;
};
void test01()
{
queue<Person>q;
Person p1("唐僧", 30);
Person p2("孙悟空", 3000);
Person p3("猪八戒", 300);
Person p4("沙僧", 3);
q.push(p1);
q.push(p2);
q.push(p3);
q.push(p4);
cout << 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 << q.size() << endl;
}
int main()
{
test01();
system("pause");
return 0;
}
