title: Why would multiple shared pointers pointing to the same memory cause memory leak?
body: <p>I am reading about shared pointers and the book say that it is bad idea having multiple shared pointers point to the same memory because if one shared_ptr reference count decrease to 0, it will deallocate that memory, making the other shared_ptr pointing to garbage. </p>
  
  <pre><code>int *z = new int;
  shared_ptr&lt;int&gt; bad1(z); 
  shared_ptr&lt;int&gt; bad2(z);
  </code></pre>
  
  <p>However, when the reference count for z becomes 0, wouldn't both shared_ptr know this?</p>