Allocation of memory to variables on the stack
On this page
This lesson contains approximately 32 minutes of video content.
Memory allocation overview
Allocation of memory to variables
Why do the size of objects stored on the stack must be known at compile-time?
What's problematic about Problematic()?
Limitations we've observed of the stack
Questions
Q0
QAMVS Q0
This question is ungraded.
Where do named objects (not declared as static/global) have their memory allocated?
Q1
QAMVS Q1
This question is ungraded.
In the video, we define the function Fact recursively. Given our definition of Fact,
invoking Fact(3) will cause how many activation records for Fact to be pushed to the stack?
Q2
QAMVS Q2
This question is ungraded.
In the video, we explicitly state that you can think of the stack as a
Q3
QAMVS Q3
This question is ungraded.
The following code introduces a variable-length array (VLA) on the stack:
int size = 0;
std::cin >> size;
int array[size];
Is this code valid per the C++ standard?
Q4
QAMVS Q4
This question is ungraded.
Given the following function,
char* GetString(std::istream& is) {
char str[255];
is >> str;
return str;
}
what's wrong with GetString's definition?
Q5
QAMVS Q5
This question is ungraded.
What memory region allows us to create an object in a function and have that object's lifetime extend beyond that function?