title: C++ how to add an element to a pointer array by exceeding size
body: <p>assume that we created dynamically allocated memory such as:</p>
  
  <pre><code>int SIZE = 10;
  int *p = new int[SIZE];
  for(int i = 0; i &lt; SIZE; ++i)
    p[i] = i;
  </code></pre>
  
  <p>it will assing 0 to 9 to our pointer array.<br>
  Then i wanted to add 10,11,12 to the array<br>
  <strong>can i do :</strong></p>
  
  <pre><code>p[10] = 10;
  p[11] = 11;
  p[12] = 12;
  </code></pre>
  
  <p><strong>or should i do:</strong></p>
  
  <pre><code>delete[] p;
  size = 13;
  p = new int[SIZE];
  for(int i = 0; i &lt; SIZE; ++i)
    p[i] = i;
  </code></pre>