PW> I'm wondering how to, from an object's constructor, to self-destruct
PW> if there is some kind of error, the object will NOT be created.
The approach is fundamentally wrong. You can only destroy an object
that has been constructed, so destruction from the constructor isn't
possible.
The only thing that comes near to what you suggest is throwing an
exception in the constructor. This will prevent the object from even
being (fully) constructed. But if you want to do that, you have to
write exception-safe code, which isn't an easy thing to do.
PW> Could someone please tell me how to do this and how to detect if the
PW> has been created or not? I'm accessing the object thru a pointer (u
PW> and delete to create and destroy it, respectively).
You can't do that except by catching an exception.
But I'm sure that there's a way to solve your problem without. Could
you please give more details about what you want to do? I (and other
people here) will be happy to help you; sounds interesting!
Thomas
---
þ MM 1.0 #0113 þ PKUNZIP.ZIP - That's what I need...
---------------
* Origin: McMeier & Son BBS (2:301/138)
|