Is it possible to set this on null?

Zarathustra adam.chrapkowski at gmail.com
Wed Aug 6 11:34:24 PDT 2008


BCS Wrote:

> Reply to Zarathustra,
> 
> > class CFoo{
> > public void destroy(){ delete this; } // ok
> > public void forget(){ this = null; }   // ok but no effect
> > }
> 
> that doesn't work because this is a hidden arg to the function, you can change 
> its value but as with any other local value that doesn't effect the value 
> used to call the function.
> 
> > void
> > main(){
> > auto l_fooA = new CFoo;
> > auto l_fooB = l_fooA;
> > l_fooA.forget; // no effect
> > l_fooA = null;  // now ok
> > l_fooB.destroy;  // ok }
> > 
> 
> 
Reply to BCS,

Ok thanks for explain it. All regards!



More information about the Digitalmars-d-learn mailing list