STL容器适配器-栈 stack

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;
};

猜你喜欢

转载自blog.csdn.net/timeinsist/article/details/78474551