Save
COMPUTER PROGRAMMING 2
UNIT 3.
Lesson 3.3
Save
Share
Learn
Content
Leaderboard
Learn
Created by
CHRISTINE JOY
Visit profile
Cards (7)
The
heap
Unused memory of the program that can be used to allocate memory dynamically when the program runs
Dynamic memory in C++
Memory in C++ program is divided into two parts: the
stack
and the
heap
Allocation
1. Use the
new operator
to allocate a block of
memory
of a specific
size
for a
particular data type
2. The
new operator
returns a
pointer
to the
allocated memory block
3. Explicitly specify the
size
of the
memory
you want to
allocate
Static memory
Memory allocated at compile time
Deallocation
1. Use the
delete
operator to deallocate memory that was previously allocated with new
2. Deallocate memory when you're done using it to avoid memory
leaks
Dynamic memory
Memory
that can be
allocated
and
deallocated
during the
runtime
of a
program
The
stack
Variables
declared inside a
function
take up
memory
from the stack