#include <iostream>
#include <queue>
#include <string>
using namespace std;
int main()
{
queue<string> qu;
//在队列的末尾添加元素
qu.push("string1");
qu.push("string2");
qu.push("string3");
qu.push("string4");
//返回队列的第一个元素
string str=qu.front();
cout<<"The first string of queue qu:"<<str<<endl;
/*___________________________________________________________________________________
执行结果:
The first string of queue qu:string1
____________________________________________________________________________________*/
//删除第一个元素
qu.pop();
str=qu.front();
cout<<"After pop,the first string of queue is:"<<str<<endl;
/*___________________________________________________________________________________
执行结果:
After pop,the first string of queue is:string2
____________________________________________________________________________________*/
//返回队列的最后一个元素
str=qu.back();
cout<<"The last string of queue qu:"<<str<<endl;
/*___________________________________________________________________________________
执行结果:
The last string of queue qu:string4
____________________________________________________________________________________*/
//返回队列元素的个数
int num=qu.size();
cout<<"The total number of queue qu is:"<<num<<endl;
/*___________________________________________________________________________________
执行结果:
The total number of queue qu is:3
____________________________________________________________________________________*/
//判断队列是否为空
cout << "Is queue qu empty? " << boolalpha << qu.empty() << endl;
/*___________________________________________________________________________________
执行结果:
Is queue qu empty? false
____________________________________________________________________________________*/
}