TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: THOMAS MAEDER
from: PAUL WANKADIA
date: 1997-04-13 20:56:00
subject: self-destruct

On 10 Apr 97, Thomas Maeder wrote to Paul Wankadia --
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.
 TM> The  approach  is  fundamentally wrong. You can only destroy an object
 TM> that has been constructed, so destruction from the  constructor  isn't
 TM> possible.
You know bloody well what I mean... {snrk}
 TM> The  only  thing  that  comes  near to what you suggest is throwing an
 TM> exception in the constructor. This will prevent the object  from  even
 TM> being  (fully)  constructed.  But  if you want to do that, you have to
 TM> write exception-safe code, which isn't an easy thing to do.
Well, I only want to create the object once at a definite place in the code,
so...
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
 TM> You can't do that except by catching an exception.
Well, tell me everything I need to know ... and then some.
 TM> But I'm sure that there's a way to solve your problem  without.
(PW slaps his head.)
I know my code is (ahem) "exceptional", but this is ridiculous...
 TM> Could you  please  give more details about what you want to do? I (and
 TM> other people here) will be happy to help you; sounds interesting!
I'll post some code in my next message ...
... you'd better promise not to laugh.
--- PPoint 2.00
---------------
* Origin: Junyer's Workshop (3:640/772.3)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.