Google's Go & Exceptions
Ali Çehreli
acehreli at yahoo.com
Tue Jan 26 15:24:19 PST 2010
Jérôme M. Berger wrote:
> Throwing exception inside constructors should be avoided because
> then the destructor is never called and you risk leaking like crazy.
That's necessarily so, because calling the destructor on the incomplete
object might cause other troubles.
On the other hand, the destructors of all of the constructed members are
called when the encapsulating object's constructor throws.
Exception-safe programming in C++ consists of a handful of guidelines
that takes care of throwing from constructors.
Ali
More information about the Digitalmars-d
mailing list