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

Lambdas: functions made on the spot

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

A lambda expression writes a small function right where you need it, for example as the test you hand to std::count_if. The compiler turns it into an object of a hidden class: captured variables become its data, and the body becomes its call operator. Follow one lambda as it copies limit, keeps its 5 when limit changes to 100, and gets called once per element, then see how [&limit] changes the answer and when a reference can dangle.

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

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