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

Kursusindhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

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

book
Dynamic Arrays

You can also allocate memory in RAM for arrays, which are called dynamic!

To create a dynamic array, just specify the type and number of elements you want in square brackets by declaring:

python

Dynamic memory is extremely useful in many situations when your program doesn’t know how much place it needs. For instance, when your code needs to read a file or you want to create an array depending on user input.

question-icon

Fill gaps to create a string 4-element dynamic array a.

;
delete []a;

Click or drag`n`drop items and fill in the blanks

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

course content

Kursusindhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

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

book
Dynamic Arrays

You can also allocate memory in RAM for arrays, which are called dynamic!

To create a dynamic array, just specify the type and number of elements you want in square brackets by declaring:

python

Dynamic memory is extremely useful in many situations when your program doesn’t know how much place it needs. For instance, when your code needs to read a file or you want to create an array depending on user input.

question-icon

Fill gaps to create a string 4-element dynamic array a.

;
delete []a;

Click or drag`n`drop items and fill in the blanks

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 6
Vi beklager, at noget gik galt. Hvad skete der?
some-alt