title: Deleting elements of a dynamic array one-by-one
body: <p>I want to delete a dynamically-allocated array by looping through all the elements and calling <code>delete</code> on each of them.<br>
  (I am doing this because I have to "move" an array to another location, that is, to copy the original array and then delete it, but that would take 2x the time than simultaneously copying each element and calling <code>delete</code> on them individually)</p>
  
  <p>I have the following code:  </p>
  
  <pre><code>int main()
  {
      int *n=new int[2];
      delete n;
      delete (n+1);
  }  
  </code></pre>
  
  <p>But i am getting a Segmentation error each time i run this....</p>
  
  <p>Although, this works fine -:  </p>
  
  <pre><code>int main()
  {
      int *n=new int[1];
      delete n;
  }    
  </code></pre>
  
  <p>So, my guess is that delete is somehow deleting the whole array instead of a single element!  </p>
  
  <p>Could anyone please explain if my guess is right, and if it is, suggest a possible workaround?  </p>
  
  <p>I am using GCC 4.7.3 on Ubuntu 13.04</p>