On 10.01.2016 15:32, Jack wrote:
//////////////////////////////////////////


class Foo()

Those parentheses make this a (zero parameter) class template. I suppose you just want a plain class. Drop them then.

{
  void bar()
  {
  writeln("Hello World");
  }
}

class Bar()

ditto

{

void delegate() action;

   void setAction(void delegate() dele)
   {
    action = dele;
   }

}

void main()
{
Foo foo = new Foo();
Bar bar = new Bar();
bar.setAction(&foo.bar);
bar.action();
}

/////////////////////////////////////////

Is this correct? Because I've been having trouble calling the delegate
when passing the method and I read many documentation concerning
function and delegates. I'm just confused. (Disclaimer: My code's
pattern is the same as above but it's not really my exact code)

Aside from the mentioned parentheses (and a missing import), everything's correct.

Reply via email to