D - classes
- Michael (3/3) Jan 02 2004 Why must all classes be created on the heap in D ? Where is the logic in
- Matthew (22/25) Jan 02 2004 Not withstanding the lack of factual basis to your post, it sounds like
- Ben Hinkle (2/3) Jan 02 2004 Slicing is the worst part of C++ IMHO. You run into it ten seconds into ...
- J Anderson (2/6) Jan 02 2004 If you want a stackbased - like class use a struct.
Why must all classes be created on the heap in D ? Where is the logic in that? Michael
Jan 02 2004
Why must all classes be created on the heap in D ?They do not.Where is the logic in that?Not withstanding the lack of factual basis to your post, it sounds like you're more interested in having a whinge than asking a real question. Nonetheless, I'll offer some reasons: 1. You don't have to worry about slicing 2. There's no opportunity for mis-aligned allocation 3. Non-RAII types can be garbage-collected which in most, although certainly not all, circumstances can lead to performance improvements 4. There's no chance of holding dead-references to dead stack-based instances. ftr, there's no one right approach to most things in IT, and there is certainly no proven case that either stack-based or heap-based objects are superior to the other. Horses for courses. Happy New Year -- Matthew Wilson STLSoft moderator (http://www.stlsoft.org) Contributing editor, C/C++ Users Journal (www.synesis.com.au/articles.html#columns) "You can tell a Yorkshireman, but you can't tell him much!" -- Uncle Michael ---------------------------------------------------------------------------- ---
Jan 02 2004
1. You don't have to worry about slicingSlicing is the worst part of C++ IMHO. You run into it ten seconds into the language and vow never to pass an object by value again.
Jan 02 2004
Michael wrote:Why must all classes be created on the heap in D ? Where is the logic in that? MichaelIf you want a stackbased - like class use a struct.
Jan 02 2004