Previous slide
Next slide
Toggle fullscreen
Open presenter view
Source:
https://courses.engr.illinois.edu/cs225/fa2022/resources/stack-heap/
Allocate an integer with default value
0
on the heap, allocate
p
on
main
's stack to store the address of the integer
Source:
https://courses.engr.illinois.edu/cs225/fa2022/resources/stack-heap/
Allocate a
Cube
with default width
20
on the heap, allocate
c1
on
main
's stack to store the address of the
Cube
.
Source:
https://courses.engr.illinois.edu/cs225/fa2022/resources/stack-heap/
Allocate
c2
on
main
's stack and store a copy of
c1
.
Source:
https://courses.engr.illinois.edu/cs225/fa2022/resources/stack-heap/
Call method
setLength
on
c2
, changes the width of the
Cube
pointed by both
c1
and
c2
.
Source:
https://courses.engr.illinois.edu/cs225/fa2022/resources/stack-heap/
Deallocate stack memory of
main
and return
0
.