ENع
الدرس 14 · Classes

RAII: let objects clean up

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

Memory from new, an open file, a lock: each must be given back exactly once, and hand-written cleanup is easy to skip. RAII ties a resource to an object: the constructor takes it and the destructor gives it back, and C++ runs the destructor on every way out of a scope. Follow a small class Buf as it takes four ints from the heap and returns them on an early return and during an exception.

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

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