title: Delete 2D array C++
body: <p>Are these two methods of freeing a 2D array similar?</p>
  
  <pre><code>int** M = new int*[5];
  
  for (int i = 0; i &lt; 5; ++i)
      M[i] = new int[3];
  
  for (int i = 0; i &lt; 5; ++i) {
      for (int j = 0; j &lt; 3; ++j) {
          M[i][j] = i + j;
      }
  }
  </code></pre>
  
  <p>delete I:</p>
  
  <pre><code>for (int i = 0; i &lt; 5; ++i)
      delete [] M[i];
  delete [] M;
  </code></pre>
  
  <p>and delete II:</p>
  
  <pre><code>delete [] *M;
  delete [] M;
  </code></pre>
  
  <p>Are these two code equivalent?</p>