Constraints on Types That a Container Can Hold
Almost any type can be used as the element type of a sequential container. In particular, we can define a container whose element type is itself another container. We define such containers exactly as we do any other container type: We specify the element type (which in this case is a container type) inside angle brackets:
vector<vector<string>> lines; // vector of vectors
Here lines
is a vector
whose elements are vectors
of string
s.
Note
Older compilers may require a space between the angle ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.