#1769easyC++ & Systems
Vector Growth and Iterator Invalidation
Consider the following C++ code:
#include <iostream>
#include <vector>
int main() {
std::vector<int> v = {1, 2, 3};
v.reserve(100);
auto it = v.begin();
v.push_back(4); // (1)
std::cout << *it; // (2)
}
Which statement is true?
Loading interactive editor…