Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Static Memory | Dynamic Memory
C++ Intermediate | Mobile-Friendly
course content

Course Content

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

1. Data Types and Arrays
2. References & Pointers
3. Dynamic Memory
4. Functions

Static Memory

Before we start studying the main purpose of pointers, we should understand what static and dynamic memory are.

  • Static memory or Stack: Memory allocated for all your local variables and operations in your program (stack memory).
  • Dynamic memory or Heap: An unused memory program in RAM that can be aplied for dynamic memory allocation.

Random access memory (RAM) is a computer's short-term memory for temporarily storing data that is currently in use. Let's go deep into it. Imagine that this is the area of our RAM:

As I've already told you, when we write a program, it knows how much memory space it will take up. We, for example, know that the variable type of int needs 4 bytes.

This second small rectangle will be our program. It already allocates space in itself for all its static data: its variables and arrays in the form in which we declare them. When you and I declared a one-dimensional static array, we had to specify its length and pass the constant there or manually fill elements of the array that will be stored so that the compiler itself can calculate its length. That's exactly the main rule for static memory: We know how much memory we need.

Choose correct statements:

Select a few correct answers

Everything was clear?

Section 3. Chapter 1
We're sorry to hear that something went wrong. What happened?
some-alt