ENع
الدرس 19 · Modern C++

STL containers: how std::vector grows

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

The standard library's containers are objects that own a group of elements and manage their memory for you. Follow the one you will use most, std::vector, through an eleven-line program: a small object on the stack, its elements side by side on the heap, push_back filling spare capacity, and the moment the block is full and the vector moves everything to a bigger one. See why growing invalidates old pointers, why push_back is still fast on average, and how the destructor frees it all.

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

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