Changing the Size of a vector

One of the key differences between a vector and an array is that a vector can dynamically grow to accommodate more elements. To demonstrate this, line 88 shows the current size of integers3, line 89 calls the vector’s push_back member function to add a new element containing 1000 to the end of the vector and line 90 shows the new size of integers3. Line 92 then displays integers3’s new contents.

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.