How to dynamically allocate arrays in C++
<p>I know how to dynamically allocate space for an array in C. It can be done as follows:</p>

<pre><code>L = (int*)malloc(mid*sizeof(int)); 
</code></pre>

<p>and the memory can be released by:</p>

<pre><code>free(L);
</code></pre>

<p><strong>How do I achieve the equivalent in C++?</strong> </p>

<p>Specifically, how do I use the <code>new</code> and <code>delete[]</code> keywords? Especially in the context of creating/destroying a linked list node, or creating and destroying an array whose size is given by a variable during compile time?</p>