← C++ Programming learning path
C++ Programming · Module 4 of 10

Arrays, strings and vectors

Store collections with arrays and the STL vector.

📖 Key ideas

  1. Arrays have fixed size: int a[5];
  2. std::vector<int> v grows dynamically: v.push_back(3).
  3. v.size(), v[i], v.back(), v.pop_back().
  4. std::string supports +, size(), substr, find.
  5. Prefer vector and string over raw arrays.
💡 Real-life example: A vector is an expandable suitcase; an array is a fixed-size box.
ArrayFixed-size collection
std::vectorDynamic array
push_backAdds to end of vector
substrExtracts part of a string