Beginner: How does an object delete itself?

nobody somebody at somewhere.com
Sun Sep 21 09:37:13 PDT 2008


Thanks, after some Access Violations in my code I got it to work.

But is this not better?

class Foo
{
...
     private void deleteMySelf()
     {
         for (int i = 0; i < foo.length; i++)
         {
             if (foo[i] == this)
             {
                 foo[i] = foo[$-1];

                 foo.length--;

                 delete this;

                 break; // is this still necessary?
             }
         }
     }
...
} 




More information about the Digitalmars-d-learn mailing list