C++ 'delete' an object which has a reference
<p>It seems that 'delete' (free memory in C++) does not work when I'm trying the following code...
Well, I know the reference is not suitable for "refer to an object which will be freed later on". I am just playing the code..</p>

<pre><code>class A{
public:
    int val;
    A(int val_=0):val(val_){}
};

A* ptrA = new A(10);
A &amp;refA = *ptrA;
printf("%d\n", refA.val);
delete ptrA;
refA.val = 100;
printf("%d\n", refA.val);
</code></pre>

<p>The output is :
10
100</p>
