About 10,800,000 results
Open links in new tab
  1. How does c++ std::vector work? - Stack Overflow

    Jul 2, 2010 · Using std::vector allows the use of other Standard Template Library components such as algorithms so using std::vector comes with quite a few advantages over a C style array as you get to …

  2. How to navigate through a vector using iterators? (C++)

    The goal is to access the "nth" element of a vector of strings instead of the [] operator or the "at" method. From what I understand, iterators can be used to navigate through containers, but I've ...

  3. c++ - Removing item from vector while iterating? - Stack Overflow

    Jan 17, 2011 · 0 Removing items from the middle of a vector will invalidate all iterators to that vector, so you cannot do this (update: without resorting to Wilx's suggestion). Also, if you're worried about …

  4. c++ - Initializing a two-dimensional std::vector - Stack Overflow

    Here, the vector 'v' can be visualised as a two dimensional array, with 'A_NUMBER' of rows, with 'OTHER_NUMBER' of columns with their initial value set to 'DEFAULT_VALUE'.

  5. C++ Vector of vectors - Stack Overflow

    Dec 6, 2012 · That means that in vector<vector<int>> it will parse >> as a shift operator rather than part of a template declaration. You need the extra space to indicate to the compiler that you're declaring a …

  6. 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

  7. c++ - Sorting a vector in descending order - Stack Overflow

    Jan 27, 2012 · std::sort(numbers.rbegin(), numbers.rend()); // note: reverse iterators to sort a vector in descending order? Are there any benefits or drawbacks with one approach or the other?

  8. Why use a new call with a C++ 'vector'? - Stack Overflow

    Feb 13, 2018 · std::vector<int>* v = new std::vector<int> v is a pointer to a dynamically allocated object, that dynamically allocates memory in order to store elements. As said already, you need to explictly …

  9. How to find out if an item is present in a std::vector?

    Feb 21, 2009 · You pass the std::find function the begin and end iterator from the vector you want to search, along with the element you're looking for and compare the resulting iterator to the end of the …

  10. c++ - How do I sort a vector of custom objects? - Stack Overflow

    22 Sorting such a vector or any other applicable (mutable input iterator) range of custom objects of type X can be achieved using various methods, especially including the use of standard library algorithms …