Is memory allocated for an object automatically deleted if an exception is thrown in a constructor?
<p>Suppose there is this code:</p>

<pre><code>class CFoo
{
public:
    CFoo()
    {
        iBar = new CBar();
    }
private:
    CBar* iBar;
};

....
CFoo* foo = new CFoo();
</code></pre>

<p>When the above line is executed, first memory will be allocated to hold the CFoo object. But then if the line new CBar() throws an exception (due to lack of memory) does the system automatically deallocate the memory that was previously allocated to the CFoo object? 
I presume it must, but cannot find any explicit reference saying so. If it doesn't how can the memory be deallocated by the coder as it will not have been assigned to foo?</p>
