What's the difference between these two object instantiation approaches?
<p>Suppose I have a class named A:</p>

<pre><code>Class A
{
...
}
</code></pre>

<p>And what's the difference between the following 2 approaches to instanciate an object:</p>

<pre><code>void main(void)
{
    A a;  // 1
    A *pa=new A();  // 2
}
</code></pre>

<p>As my current understanding (not sure about this yet):</p>

<ul>
<li><p>Approach 1 allocate the object a on the stack frame of the main() method, and so this object cannot deleted because that deletion doesn't make sense (don't know why yet, could someone explain that?).</p></li>
<li><p>Approach 2 allocate the object a on the heap of the process and also a A* vairable <em>pa</em> on the stack frame of the main() method, so the object can be deleted and and the pa can be assigned null after the deletion.</p></li>
</ul>

<p>Am I right? If my understanding is correct, could someone tell me why i cannot delete the <em>a</em> object from the stack in approach 1?</p>

<p>Many thanks...</p>
