deleting elements in array of pointer (C++) : <p>Suppose I have an array of pointers like</p>

<pre><code>Person** p = new Person*[5]
// p is filled with five person pointer (say p[2] = *John where John is an object of person
// now we want to remove p[2]
delete p[2];
p[2] = p[3];
p[3] = p[4];
p[4] = nullptr;
</code></pre>

<p>The program cannot be compiled unless I remove the line of delete and nullptr.
Why will this happen? If I do not delete p[2], there should be problem as I cannot access john again?</p>
