Is it safe to use the "realloc" after the "new" operator in C++? : <p>As far as I know, there is no exact alternative for the <code>realloc</code> of <code>C</code> in <code>C++</code> like the <code>new</code> for <code>malloc</code>. However, when I use the <code>realloc</code>  in <code>C++</code> to alter the memory allocated by the <code>new</code> operator, it works fine. </p>

<p>Is it safe to use those two (<code>new</code> and <code>realloc</code>) like I do in the codes below or it can lead to some problems?</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;cstdlib&gt;

int main()
{
    int size = 5;
    int * arr = new int[size]{ 1,3,5,7,9 };

    for (int i = 0; i &lt; size; i++)
        std::cout &lt;&lt; *(arr + i) &lt;&lt; (i &lt; size - 1 ? ' ' : '\n');

    size++;
    arr = (int*)realloc(arr, size * sizeof(int));

    *(arr + size - 1) = 11;
    for (int i = 0; i &lt; size; i++)
        std::cout &lt;&lt; *(arr + i) &lt;&lt; (i &lt; size - 1 ? ' ' : '\n');

    delete[] arr;
    //free(arr);

    std::cin.get();
    return 0;
}
</code></pre>

<p>Also, which operator should I use in such a case to free the memory:  <code>delete[]</code> of <code>free()</code>?</p>
