|
-
May 19th, 2009, 10:01 PM
#2
Re: Is this "good" coding style... ?
I come from a heavy Java background, so I'm used to things cleaning up after themselves...
Don't try to make C++ behave like Java. Learn the appropriate C++ techniques (RAII, smart pointers and so on) and use them. Also, don't use new except when you absolutely need to, and you avoid the need for those in the first place.
Anywho, is it still acceptable to use "delete this" within a class?
I would say it's generally not a good idea, because if you're going to do that you have to enforce that the object can only be created via new (not on the stack, not global, not by new[]) or else you potentially will have major problems.
See: http://www.parashift.com/c++-faq-lit...html#faq-16.15
Last edited by Speedo; May 19th, 2009 at 10:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|