Destructing Member Objects

Brian White bcwhite at pobox.com
Sat Apr 5 22:54:30 PDT 2008


> class foo
> {
>   private ~this()
>   {
>   }
> 
>   public kill()
>   {
>   // call any specific code you want here
>   delete this;
>   }
> }
> 
> Then use foo.kill() instead of delete foo. Ugly, but works, I think.

I don't think it does work.  If you have a "scope" variable, for 
example, the compiler won't call "kill" when deleting the object.

-- Brian


More information about the Digitalmars-d-learn mailing list