ENع
الدرس 10 · Memory

The heap: new and delete

لم يُترجم بعد؛ يُعرض باللغة الإنجليزية

Local variables live on the stack and vanish when their function returns. When data must outlive a function, or its size is only known while the program runs, you ask the heap for memory with new and give it back with delete. Follow a nine-line program as new returns addresses that pointers keep, *p follows one to change a value, delete leaves a dangling pointer, and a forgotten delete becomes a leak.

12 دقيقة9 خطوات5 أسئلةIntermediate
شكل 10 · تفاعلي
جارٍ تحميل الرسم…
أو ← →

اختبار يتاح بعد الخطوة الأخيرة.