Range-based for loop
Në shqip: Cikli for mbi koleksion
ShpjegimiSQ
Cikli for i bazuar në koleksion (që nga C++11) kalon nëpër çdo element pa numërues: for (int n : notat). Me auto& mund t'i ndryshosh elementet direkt, dhe me const auto& i lexon pa i kopjuar.
EnglishEN
The range-based for loop (since C++11) goes through every item without a counter: for (int n : grades). With auto& you can change the items directly, and with const auto& you read them without copying.
Si ta mendosh
Si mësuesja që ua shpërndan fletët e provimit të gjithë nxënësve në rresht, pa i numëruar.
Lexoje në anglisht
Like the teacher handing out exam papers to everyone in the row, without counting them.
Shembull kodicpp
std::vector<int> notat = {4, 5, 3};
for (int& n : notat) n++; // rrit çdo notë
for (const auto& n : notat) std::cout << n << " ";