On Wed, 10 May 2006 15:17:57 -0700, puzzlecracker wrote:
When ctor throws an exception, dtor is not called for that object
(correct me if I am wrong) - then how would already allocated memebers
de-allocated?
Correct. If an exception propogates out of a ctor, the dtor for that
object will not be invoked as that object had not completed construction.
Any member variables of that object that had ben completely constructed
will be destroyed in the reverse order that they were constructed in (as
normal).
Note that the destructor of a pointer-to-object doesn't do anything...
that's what std::auto_ptr (and other relatives of it) are for.