P.11 call vector reserve(100) instead of vector(100)

This commit is contained in:
Derek Li 2016-10-04 12:55:52 +01:00 committed by GitHub
parent 7b4a1903ec
commit 6c29e226d8

View File

@ -998,7 +998,8 @@ This is low-level, verbose, and error-prone.
For example, we "forgot" to test for memory exhaustion.
Instead, we could use `vector`:
vector<int> v(100);
vector<int> v;
v.reserve(100);
// ...
for (int x; cin >> x; ) {
// ... check that x is valid ...