title: Removing elements from dynamic arrays without changing the index order
body: <p>I've been trying to erase an element from an array without changing the index order, for instance:</p>
  
  <pre><code>class MyObject  
  {  
      int id;  
  public:  
      MyObject() { }  
      void setId( int i ) { id = i; }  
      void showId() { std::cout &lt;&lt; "ID: "&lt;&lt; id &lt;&lt; "\n"; }
  };  
  MyObject *myArray;
  
  int main ( )  
  {  
      myArray = new myArray[6];  
      for( int i = 0; i &lt; 6; i++ )  
      {  
          myArray[i]-&gt;setId(i); 
          myArray[i]-&gt;showId();
      }  
  }  
  </code></pre>
  
  <p>I want to remove <code>myArray[3]</code> without changing the index of the others. e.g:</p>
  
  <pre><code>myArray[0] = ID: 1  
  myArray[1] = ID: 2  
  myArray[2] = nothing  
  myArray[3] = ID: 4  
  myArray[4] = ID: 5  
  myArray[5] = ID: 6    
  </code></pre>
  
  <p>I've tried to use use <code>memset()</code>, but it didn't work.</p>
  
  <pre><code>memset(&amp;myArray[3],0,sizeof(MyObject));
  </code></pre>