1概念
- 先進先出
- 不能進行遍歷
- 不支持隨機存儲,只能從隊尾插入 對頭獲取元素
- 沒有迭代器
2常用API
2.1構造函數
2.2stack數據存儲函數
2.3stack賦值操作函數
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();
}