D delegate

来源:互联网 发布:java自行车是哪个国家 编辑:程序博客网 时间:2024/06/05 15:01

D语言:

 void delegate(TCPEvent) delegate(AsyncTCPConnection) del; == return (viod delegate(TCPEvent)) input AsyncTCPConnection ;

Like as:
C:

void (*fp)(TCPEvent);fp (*del)(AsyncTCPConnection);

Delegates
There are no pointers-to-members in D, but a more useful concept called delegates are supported. Delegates are an aggregate of two pieces of data: an object reference and a pointer to a non-static member function, or a pointer to a closure and a pointer to a nested function. The object reference forms the this pointer when the function is called.

Delegates are declared similarly to function pointers, except that the keyword delegate takes the place of (*), and the identifier occurs afterwards:

官方的注解,简单的来说就相当于C语言中的函数指针~~用来回调

0 0
原创粉丝点击