1概念
- 先进先出
- 不能进行遍历
- 不支持随机存储,只能从队尾插入 对头获取元素
- 没有迭代器
2常用API
2.1构造函数
2.2stack数据存储函数
2.3stack赋值操作函数![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/830d5eb9968cda927f53bfb6e4b8e524.png)
2.4stack大小函数
3代码
#include<iostream>
#include<queue>
using namespace std;
void test1(){
queue<int> q;
q.push(10);
q.push(20);
q.push(30);
q.push(40);
cout<<q.back()<<" ";
//输出
while(q.size()>0){
cout<<q.front()<<" ";
q.pop();
}
}
int main(){
test1();
}