Recall & Review
beginner
What is the call stack in C++?
The call stack is a special area in memory that stores information about active functions or methods. It keeps track of where each function should return after it finishes.
Click to reveal answer
beginner
What happens when a function is called in terms of the call stack?
When a function is called, a new stack frame is created and pushed onto the call stack. This frame holds the function's parameters, local variables, and return address.
Click to reveal answer
intermediate
Explain what a stack frame contains.
A stack frame contains the function's parameters, local variables, and the return address to know where to continue after the function finishes.
Click to reveal answer
beginner
What happens to the call stack when a function returns?
When a function returns, its stack frame is popped off the call stack, and the program continues execution from the return address stored in the previous stack frame.
Click to reveal answer
intermediate
What is a stack overflow and when can it happen?
A stack overflow happens when the call stack grows beyond its limit, usually because of too many nested function calls or infinite recursion, causing the program to crash.
Click to reveal answer
What does the call stack store when a function is called?
✗ Incorrect
The call stack stores the function's parameters, local variables, and return address in a stack frame.
What happens to the call stack when a function finishes execution?
✗ Incorrect
When a function finishes, its stack frame is popped off the call stack.
Which of these can cause a stack overflow?
✗ Incorrect
Too many nested function calls or infinite recursion can cause the call stack to overflow.
Where does the program continue after a function returns?
✗ Incorrect
The program continues at the return address stored in the previous stack frame.
What is NOT stored in a stack frame?
✗ Incorrect
Global variables are stored in a different memory area, not in the stack frame.
Describe the lifecycle of a function call in terms of the call stack.
Think about what happens when you call a function and when it finishes.
You got /5 concepts.
Explain what causes a stack overflow and how it relates to the call stack.
Imagine calling functions inside functions without stopping.
You got /4 concepts.