std::stack
来源:互联网 发布:linux如何编辑文档 编辑:程序博客网 时间:2024/06/06 02:26
成员函数
//函数签名//initialize(1)//explicit stack(const container_type& ctnr);//move - initialize(2)//explicit stack(container_type&& ctnr = container_type());//allocator(3)//template <class Alloc> explicit stack(const Alloc& alloc);//init + allocator(4)//template <class Alloc> stack(const container_type& ctnr, const Alloc& alloc);//move - init + allocator(5)//template <class Alloc> stack(container_type&& ctnr, const Alloc& alloc);//copy + allocator(6)//template <class Alloc> stack(const stack& x, const Alloc& alloc);//move + allocator(7)//template <class Alloc> stack(stack&& x, const Alloc& alloc);//bool empty() const;//size_type size() const;//reference& top();//const_reference& top() const;//void push(const value_type& val);//void push(value_type&& val);//template <class... Args> void emplace(Args&&... args);#include<iostream>#include<stack>#include<queue>#include<vector>#include<string>using namespace std;int main(){ deque<int> my_deque(3, 100); vector<int> my_vector(2, 200); stack<int> first_stack; stack<int> second_stack(my_deque); stack<int, vector<int>> third_stack; stack<int,vector<int>> fourth_stack(my_vector); stack<string> fifth_stack; stack<string> six_stack; if (fourth_stack.empty()) cout << "fourth_stack is empty ." << endl; else cout << "fourth_stack is not empty ." << endl; cout << "fourth_stack's size is " << fourth_stack.size() << endl; cout << "fourth_stack's top is " << fourth_stack.top() << endl; fourth_stack.push(50); fourth_stack.push(10); cout << "fourth_stack's top is " << fourth_stack.top() << endl; fifth_stack.push("abc"); fifth_stack.swap(six_stack); cout << "six_stack's top is " << six_stack.top() << endl; return 0;}//输出://fourth_stack is not empty .//fourth_stack's size is 2//fourth_stack's top is 200//fourth_stack's top is 10//six_stack's top is abc
0 0
- std::stack
- acm算法之std::queue与std::stack
- std::map的陷阱 stack overflow
- 【C++ STL应用与实现】12: 如何使用std::stack
- C++/C++11中std::stack的使用
- std::stack<T>和std::queue<T>在执行频率比较高的程序中,效率太低
- std
- std
- std
- 条件变量实例:生产者-消费者模式的后进先出型(std::stack)缓冲区
- stack
- stack
- stack
- stack
- Stack
- Stack
- Stack
- Stack
- CheckBoxDemo
- 简历的主线这样写,就会有面试通知!
- jQuery全屏滚动插件fullPage(转自https://github.com/powy1993/fullpage)
- TinyXML入门
- 《java设计模式》之观察者模式
- std::stack
- 包装类 的用法
- 认识索引
- android:Activity启动模式之singleTask(一)
- 常见的Restrictions用法
- Generate Signed APK: Errors while building APK. wear:packageRelease FAILED
- 【MinaFile】【十四】【2.0】多文件处理粘包之服务器接收端
- 1042. Shuffling Machine (20)
- Email 格式验证的正则表达式