stl :: (4) stack container API

Only the top element of the stack has a chance to be accessed by the outside world. The stack does not provide traversal functions, nor does it provide iterators.

stack constructor

stack<T> stkT;                        // stack采用模板类实现,默认构造
stack(const stack &stk);   // 拷贝构造函数

stack assignment operation

stack& operator=(const stack &stk);  // 重载=

stack data access

push(elem);       // 向栈顶添加元素
pop();                // 从栈顶移除第一个元素
top();                 // 返回栈顶元素

Stack size operation

empty();            // 判断栈是否为空
size();                 // 返回栈的大小

Guess you like

Origin blog.csdn.net/qq_40329851/article/details/114379194