title: double pointer reference in C++
body: <p>This may a stupid question, but I'm gonna ask it anyway:</p>
  
  <p>Suppose you have a pointer: <code>Object* pointer</code>  which points at a dynamically allocated object.</p>
  
  <pre><code>class PointClass
  {
   Array&lt;Object*&gt; m_array1;
   Array&lt;Object*&gt; m_array2;
  
   void Delete1()
   {
       for (int i = 0; i &lt; m_array1.Length; i++)
       {
           delete m_array1[i];
       }
   }
  
  void Delete2()
  {
      for (int i = 0; i &lt; m_array2.Length; i++)
      {
          delete m_array2[i];
      }
   }
  }
  </code></pre>
  
  <p>Now, you put your pointer both in <code>m_array1</code> and in <code>m_array2</code>.</p>
  
  <p>When you try to delete the arrays, in one of them you will have a pointer which points to a deallocated space, so you can't delete it again!</p>
  
  <p>I can't just assign the pointers NULL after the deletion because it wouldn't affect the pointer in the other array.  </p>
  
  <p>How would you solve it?  </p>