mobile wallpaper 1
mobile wallpaper 2
mobile wallpaper 3
mobile wallpaper 4
132 words
1 minute
stack容器 - CPP STL
2026-10-10

stack基本概念#

概念:stack是一种先进后出(First In,Last out,FILO)的数据结构,它只有一个出口

stack-image

栈中只有顶端元素才可以被外界使用,因此栈不允许有遍历行为

栈底高地址,栈顶低地址

栈中进入数据 — 入栈push

栈中弹出数据 — 出栈pop

stack常用接口#

功能描述:#

栈容器常用的对外接口

构造函数:

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

赋值操作:

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

数据存取:

push(elem); //向栈中添加elem
pop(); //删除最顶端第一个元素
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
Author
Memki
Published at
2026-10-10
License
CC BY-NC-SA 4.0

Some information may be outdated

Table of Contents