fork download
  1. #include <vector>
  2. #include <iostream>
  3.  
  4. int main() {
  5. std::vector<int> v = {1,2,3,4,5,6};
  6. int& i = v[2]; //should point to 3
  7. std::cout << i << '\n';
  8. v.resize(5000);
  9. v.push_back(7);
  10. v.push_back(8);
  11. v.push_back(9);
  12. std::cout << i;
  13. }
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
3
0