June 2025
Intermediate to advanced
1093 pages
33h 24m
English
std::arrayYou specify the number of elements this container should hold at creation. It neither grows nor shrinks; you access its elements with an index or iterate over ranges.
std::vectorThis all-rounder stores its elements consecutively. You access its elements via a numeric index or iterate over ranges. In addition, it grows automatically when you add elements.
I strive not to use the ambiguous term arrays, but always write either array for std::array or C-array for typ[]. In other sources, the latter is usually simply called array—or, in some texts, field.[ 13 ]
You use the array when you know in advance how many elements you need. As you can see in the first line of main(), you ...
Read now
Unlock full access