Saaa wrote:
> Ok, disregard my last comment :D
> How should I do this then? 

class Foo
{
  C* c;

  this(ref C c)
  {
    this.c = &c;
  }

  int invoke()
  {
    return (*c).method();
  }
}

void main()
{
  // ...
  deleg = &(new Foo(c)).invoke;
}

Or something similar.

This is dangerous.  Do not allow either the Foo instance or the delegate
to survive past the end of c's scope.

It is simpler and safer to just update the delegate.

Reply via email to