如何返回一个函数,然后再调用它?

me *_* me 3 d return function return-type

所以假设我有这个struct a和一个void方法,它将该struct作为参数.我如何能够通过另一种方法返回void方法,然后再调用它?

我的代码看起来像这样:

struct Script{
    //variables
}

void foo(Script e)
{

}

function getfoo()
{
    return foo;
}

void main(string[] args)
{

    writeln("Hello World!");
    stdin.readln();
}
Run Code Online (Sandbox Code Playgroud)

And*_*vić 8

import std.stdio;

struct Script
{
    int x, y;
}

void foo(Script e)
{
    writeln("Got: ", e);
}

void function(Script e) getfoo()
{
    return &foo;
}

void main(string[] args)
{
    auto func = getfoo();
    func(Script(1, 2));
}
Run Code Online (Sandbox Code Playgroud)