Static pointer and operator new
<pre><code>class X {
public:
    X(int i) : num(i){}
    int num;
};

void f(int i){

    static X* px1 = new X(i);
    X* px2 = new X(i);
    cout&lt;&lt;px1-&gt;num;
    cout&lt;&lt;px2-&gt;num&lt;&lt;' ';

};

void main(){
    for (int i=0;i&lt;5;i++) 
        f(i);
}
</code></pre>

<p>This code will output <code>00 01 02 03 04</code>, but I don't quite understand why static pointer <code>px1</code> can't change its value using <code>operator new</code>. </p>

<p>Also, this code has memory leakage problem. Can I use <code>delete</code> with <code>px1</code>? Will using <code>delete</code> on both pointers solve memory leakage problem?</p>
