title: getting pointers to vector elements
body: <p>I run into an issue which I don't quite understand: </p>
  
  <p>I am creating an object Edge with </p>
  
  <pre><code>edge_vec1.push_back(Edge(src,dest));
  </code></pre>
  
  <p>Then I want to keep a pointer to this Edge in a separate vector: </p>
  
  <pre><code>edge_vec2.push_back(&amp;edge_vec1.back());
  </code></pre>
  
  <p>However, once I add the second Edge object, the pointer to the first Edge in edge_vec2 is invalidated(gets some random data). Is it because the pointer in edge_vec2 actually points to some place in edge_vec1, and not the underlying element? I can avoid this by creating my Edge objects on the heap, but I'd like to understand what's going on.</p>
  
  <p>Thank you.</p>