c++ STL函数大全(七): stack

stack  即 栈, 遵循原则 后入先出 LIFO 

 0 准备

#include

1 initialize & assignment

stack stk;

2. operator

2.1 add

stk.push(66);

2.2 delete

stk.pop()  //弹出最上面的元素

2.3 query

stk.empty();

stk.size();

stk.top();

 

2.4 change

    stack stk;
    stk.push(3);
    stk.push(9);
    stack hedq;
    hedq.push(66);
    hedq.push(88);
    hedq.push(999);

    stk.swap(hedq);

    while(!stk.empty()){
        cout<< stk.top()<

 

 

3. 常见用法

 

你可能感兴趣的:(c++)