Ch 9 · Vectors & Strings · C++
Topic 9 of 13 in C++ — Complete Tutorial (Beginner) — 2 lessons.
std::vector
A vector is C++'s growable array from the STL — far safer and easier than C-style arrays. It knows its own size, grows automatically with push_back, and you access elements with [index] (starting at 0). Vectors are the default container for a list of values in modern C++; reach for one whenever you need a sequence you can add to.
std::string
C++'s string class makes text easy and safe, unlike C's char arrays. You can join strings with +, compare them with ==, get the length with .length(), and use many built-in methods. Strings grow automatically and manage their own memory, so you never worry about buffer sizes or null terminators.