www.digitalmars.com         C & C++   DMDScript  

D - destructors

reply imr1984 <imr1984_member pathlink.com> writes:
As D is a GC language, does that mean that ~this() is kinda redundant, except
when using auto classes ? When should one use an auto class? In the destructor
of an auto class, should all dynamic resources be deleted explicitly ?
Jan 06 2004
parent Andy Friesen <andy ikagames.com> writes:
imr1984 wrote:
 As D is a GC language, does that mean that ~this() is kinda redundant, except
 when using auto classes ? When should one use an auto class? In the destructor
 of an auto class, should all dynamic resources be deleted explicitly ?
Destructors are mainly used to deallocate resources that are not under the GC's thumb. When interfacing with C libraries, for instance, you typically get pointers to structs (or whatever) from the library. Unless the library itself was coded in D, you nede to free it explicitly. Destructors are the place to do it. -- andy
Jan 06 2004