#include <iostream>
#include <vector>
#include <string>

using namespace std;


int main() {

	vector<string> arr;
	
	arr.push_back("one");
	arr.push_back("two");
	arr.push_back("three");
	
	auto& x = arr[2];
	
	cout << "addr x: " << &x << endl; 
	
	/*
	for (int i=0; i<1000; ++i) {
        arr.push_back("num: " + i);
    }*/
    
    cout << "addr x: " << &x << endl; 
    
    auto& x2 = arr[2];
    
    
    cout << "addr x2: " << &x2 << endl; 
    
    cout << x << endl; // segfault arr had been reallocated x points to freed memory
	
	return 0;
}