C++ STL notes

Vector

  1. reserve() and resize() are different
    1. reserve() change the capacity of the vector can hold, has no effect on the current items/does not change the size of the vector
      1. Need to use push_back() to add elements instead of using [] access
    2. resize() change the actual size of the vector, inserting default values to the vector, thus can use [] to modify

Subscribe to TheXYZLab Blog

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe