On Thu, Jun 06, 2002, Christoph Bugel wrote about "Re: Some C++ Questions":
> > And never do something like "delete this"!
> 
> I guess "never" is not the correct word.
> There *are* legitimate uses of "delete this",
> For example in the RCProxy design pattern.

I'm not a design-patterns expert, so maybe I'm missing something, but
how can you do "delete this" from within an object? First, I don't see
how you know that this object was dynamically-allocated (it might have
been on the stack, allocated as part of an array of objects, allocated
with placement-new, etc.).

Second, what happens after the "delete this"? The method continues to
run but the object was destructed; If you do anything except "return"
after the "delete this" you might accidentally try to use members of
the deleted object...

-- 
Nadav Har'El                        |      Thursday, Jun 6 2002, 27 Sivan 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |A thing is not necessarily true because a
http://nadav.harel.org.il           |man dies for it. - Oscar Wilde

=================================================================
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to