August 2012
Intermediate to advanced
976 pages
30h 17m
English
vectorsAs with any class type, the vector template controls how we define and initialize vectors. Table 3.4 (p. 99) lists the most common ways to define vectors.
Table 3.4. Ways to Initialize a vector
We can default initialize a vector (§ 2.2.1, p. 44), which creates an empty vector of the specified type:
vector<string> svec; // default initialization; svec has no elements
It might seem that an empty vector would be of little use. However, as we’ll see shortly, we can (efficiently) add elements to a vector at ...
Read now
Unlock full access