title: Changing an object after pushing its address to a vector
body: <p>I have a question:</p>
  
  <pre><code>class B : public class A {
  public:
    vector&lt;int*&gt; vec; 
  };
  
  class A  {
  };
  
  vector&lt;A*&gt; vec_a;
  vector&lt;B*&gt; vec_b;
  </code></pre>
  
  <p>if I push back an object of class <code>B</code> into both vectors.</p>
  
  <pre><code>B* b = new B;
  vec_a.push_back(b);
  vec_b.push_back(b);
  </code></pre>
  
  <p>then after that, I change something inside the object of class <code>B</code>,</p>
  
  <p>such as:</p>
  
  <pre><code>int* i = ....
  vec_b[0].push_back(i);
  </code></pre>
  
  <p>Does the <code>vec_a</code> change? </p>
  
  <p>I am confused with that since I have checked that when vector push_back, it will only create a copy. But when I checked with the above codes, it changes. Are the two vectors hold a shared memory of object <code>b</code>?</p>
  
  <p>Thanks</p>