← C++ Programming learning pathC++ Programming · Module 4 of 10
Arrays, strings and vectors
Store collections with arrays and the STL vector.
📖 Key ideas
- Arrays have fixed size: int a[5];
- std::vector<int> v grows dynamically: v.push_back(3).
- v.size(), v[i], v.back(), v.pop_back().
- std::string supports +, size(), substr, find.
- 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