August 2012
Intermediate to advanced
976 pages
30h 17m
English
vector OperationsIn addition to push_back, vector provides only a few other operations, most of which are similar to the corresponding operations on strings. Table 3.5 lists the most important ones.
Table 3.5. vector Operations
We access the elements of a vector the same way that we access the characters in a string: through their position in the vector. For example, we can use a range for (§ 3.2.3, p. 91) to process all the elements in a vector:
vector<int> v{1,2,3,4,5,6,7,8,9};for (auto &i : v) // for each element in v (note: ...
Read now
Unlock full access