About 50 results
Open links in new tab
  1. Iterate through a C++ Vector using a 'for' loop - Stack Overflow

    Oct 3, 2012 · I am new to the C++ language. I have been starting to use vectors, and have noticed that in all of the code I see to iterate though a vector via indices, the first parameter of the for loop is always

  2. c++20 - How do I write a range-based for loop in C++ which iterates ...

    Feb 14, 2025 · How do I write a range-based for loop in C++ which iterates over a sequence of integers? The canonical solution prior to C++ 20 was the typical for loop, which is well known:

  3. for loop - How to iterate through a list of objects in C++? - Stack ...

    Mar 8, 2014 · Learn how to iterate through a list of objects in C++ using various methods and techniques.

  4. What is `template for` in C++26? - Stack Overflow

    Jul 5, 2025 · 57 template for is a new kind of loop called an expansion statement introduced in C++26 by P1306. Unlike all the other C++ loops, where the looping is based on some runtime condition, an …

  5. c++ - How do you loop through a std::map? - Stack Overflow

    I want to iterate through each element in the map<string, int> without knowing any of its string-int values or keys. What I have so far: void output(map<string, int> table) { m...

  6. c++ - How to break out of a loop from inside a switch? - Stack Overflow

    The break keyword in C++ only terminates the most-nested enclosing iteration or switch statement. Thus, you couldn't break out of the while (true) loop directly within the switch statement; however you …

  7. How to use for each loop in c++ - Stack Overflow

    Jun 24, 2013 · It exists in C++11. Make sure you use a compiler that can handle C++11, and make sure you enable the required options for that.

  8. more modern way of looping through C++ arrays - Stack Overflow

    In C/C++ sizeof. always gives the number of bytes in the entire object, and arrays are treated as one object. Note: sizeof a pointer--to the first element of an array or to a single object--gives the size of …

  9. c++ - Neatest way to loop over a range of integers - Stack Overflow

    73 Since C++11 introduced the range-based for loop (range-based for in c++11), what is the neatest way to express looping over a range of integers? Instead of

  10. c++ - Range based loop: get item by value or reference to const ...

    Range based loop: get item by value or reference to const? Asked 12 years, 11 months ago Modified 4 years, 9 months ago Viewed 148k times