title: Conserving memory/programming efficiently when using `std::shared_ptr`
body: <p>I am trying to create a bunch of shared pointers and put them into various containers.</p>
  
  <p>Using raw pointers I would think to do the following:</p>
  
  <pre><code>Container a, b, c;
  MyClass *ptr;
  while(!finishedCreating){
      ptr = new MyClass(SOME_CHANGING_THING);
      a.add(ptr);
      b.add(ptr);
      c.add(ptr);
  }
  </code></pre>
  
  <p>But of course now if I want to destruct <code>a</code>, <code>b</code>, and <code>c</code> I would need to delete the pointers that they contain. If I did the following:</p>
  
  <pre><code>~Container{
      delete[] myListOfPointers;
  }
  </code></pre>
  
  <p>I would get an error when destructing because deleting <code>a</code> would delete the same memory that <code>b</code> and <code>c</code> are supposed to get rid of. </p>
  
  <p>Enter smart pointers, specifically, <code>std::shared_ptr</code>. I would like to do something similar to before where I can create a single entity and use it to point to tons of memory locations but I'm not sure how to do this? </p>
  
  <p>Would I want to create a pointer to a <code>std::shared_ptr</code> so that I can reallocate that pointer such as</p>
  
  <pre><code>std::shared_ptr&lt;MyClass&gt; *ptr = new std::shared_ptr&lt;MyClass&gt;(new MyClass(THING));
  </code></pre>