c++ - 调用堆栈是否在 C++ 中先入/先出?

标签 c++ callstack

Each time we call the function, the stack of activation records (usually just called the stack) grows with one record. Conversely, when the function returns, its record is no longer used and so on. The stack (also called the call stack) is a data structure that grows and shrinks at one end according to the rule first in and first out.


最后一行是否正确?我在 Bjarne Stroustrup 的《使用 C++ 的编程原理和实践》一书中读到了它。

最佳答案

这是一个错误。堆栈是,根据定义 , 后进先出 (LIFO)。先进先出 (FIFO) 数据结构将是一个队列,而不是一个堆栈。

关于c++ - 调用堆栈是否在 C++ 中先入/先出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65193521/

相关文章:

c++ - 如何静态检查模板的类型 T 是否为 std::vector<U>,其中 U 为 float、double 或 integral

javascript - 负数的阶乘超过最大调用堆栈大小

java - Mockito - 当主类包含许多其他类时模拟的深度?

python - 如何在调用函数时打印它们?

c++ - 如何在我的 Mac 上安装 boost?

C++ [] 具有多个参数的数组运算符?

c++ - _chkstk() 函数的目的是什么?

c - Linux进程堆栈被局部变量溢出(堆栈保护)

c++ - 子对象有一个指向其父对象的指针是不好的做法吗?

c++ - 在 C++ 中创建一个静态初始化类