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

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

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

book
Delete

You can "communicate" with your variable in a heap by using the pointer:

123
int *x = new int; *x = 42; cout << *x;
copy

If the RAM space we use for our code runs out, the program will crash. Your RAM is not limitless, and after the program execution, we should always take care of clearing the area in memory that we originally allocated:

To clean the space in your code, use the keyword delete and the pointer, which contains the address of the memory we want to free:

python

Remember! For each new operator should always exist delete!

question-icon

Delete the pointer x:

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 4

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

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

book
Delete

You can "communicate" with your variable in a heap by using the pointer:

123
int *x = new int; *x = 42; cout << *x;
copy

If the RAM space we use for our code runs out, the program will crash. Your RAM is not limitless, and after the program execution, we should always take care of clearing the area in memory that we originally allocated:

To clean the space in your code, use the keyword delete and the pointer, which contains the address of the memory we want to free:

python

Remember! For each new operator should always exist delete!

question-icon

Delete the pointer x:

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 4
Vi beklager at noe gikk galt. Hva skjedde?
some-alt