// iterator invalidation // Mikhail Nesterenko // 5/9/2016 #include #include using std::vector; using std::cout; int main(){ vector v(5); vector::iterator p; p = v.begin()+3; // p points to 4th element v.erase(v.begin()); // erasing the first element of the vector // this invalidates p cout << *p; // p is invalidated, result is unspecified // run-time error }