STL容器适配器-栈 stack

来源:互联网 发布:葛优 知乎 编辑:程序博客网 时间:2024/06/06 01:37
template<class T,     class Cont = deque<T> >class stack {public:    //类型定义    typedef Cont::allocator_type allocator_type;    typedef Cont::value_type value_type;    typedef Cont::size_type size_type;    //构造函数    explicit stack(const allocator_type& al = allocator_type()) const;    //如果容器为空返回true    bool empty() const;    //返回容器中元素个数    size_type size() const;    //返回容器分配器    allocator_type get_allocator() const;    //返回栈顶元素引用    value_type& top();    const value_type& top() const;    //入栈    void push(const value_type& x);    //出栈    void pop();protected:    Cont c;};
原创粉丝点击