132 words
1 minute
stack容器 - CPP STL
stack基本概念
概念:stack是一种先进后出(First In,Last out,FILO)的数据结构,它只有一个出口

栈中只有顶端元素才可以被外界使用,因此栈不允许有遍历行为
栈底高地址,栈顶低地址
栈中进入数据 — 入栈push
栈中弹出数据 — 出栈pop
stack常用接口
功能描述:
栈容器常用的对外接口
构造函数:
stack<T> stk; //stack采用模板类实现,stack的默认构造形式stack(const stack &stk); //拷贝构造赋值操作:
stack& operator=(const stack &stk); //重载=数据存取:
push(elem); //向栈中添加elempop(); //删除最顶端第一个元素top(); //返回栈顶元素大小操作:
empty(); //判断是否空size(); //返回栈大小Video
Share
If this article helped you, please share it with others!
stack容器 - CPP STL
https://www.bilibili.com/video/BV1et411b73Z/?p=211 Some information may be outdated
Related Posts Smart