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

Delete

Stryg for at vise menuen

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

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

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:

delete x;

Remember! For each new operator should always exist delete!

question-icon

Delete the pointer x:

Klik eller træk`n`drop elementer og udfyld hullerne

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 3. Kapitel 4

Spørg AI

expand

Spørg AI

ChatGPT

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

Sektion 3. Kapitel 4
some-alt