delphi: reference to(匿名方法)
来源:互联网 发布:windows升级助手 编辑:程序博客网 时间:2024/06/05 11:02
正常函数类型的对象需在外部实现,单reference to可以在函数内实现,有子函数的效果。具体代码示例如下:
unit Unit6;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TYDForm = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TYDForm = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
YDForm: TYDForm;
YDForm: TYDForm;
implementation
{$R *.dfm}
Type
TFun = function: string;
TReferenceFun = reference to function: string;
TFun = function: string;
TReferenceFun = reference to function: string;
function TestFun: string;
begin
Result := '函数类型对象用法';
end;
begin
Result := '函数类型对象用法';
end;
procedure TYDForm.FormCreate(Sender: TObject);
var
Fun: TFun;
RFun: TReferenceFun;
str: Integer;
begin
RFun := function: string
begin
Result := '匿名函数reference用法';
end;
ShowMessage(RFun);
var
Fun: TFun;
RFun: TReferenceFun;
str: Integer;
begin
RFun := function: string
begin
Result := '匿名函数reference用法';
end;
ShowMessage(RFun);
Fun := TestFun;
ShowMessage(Fun);
end;
ShowMessage(Fun);
end;
end.
阅读全文
0 0
- delphi: reference to(匿名方法)
- Delphi 2009 中的匿名方法(reference to)
- Delphi 2009 中的匿名方法(reference to) 研究
- Delphi 2010 匿名方法
- Delphi匿名方法
- "undefined reference to" 问题解决方法
- undefined reference to" 问题解决方法
- undefined reference to 问题解决方法
- undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- "undefined reference to" 问题解决方法
- poj 3026 Borg Maze 【bfs+最小生成树】
- IO流文件的读取与写入
- Qt5.7 编译V-REP
- Codeforces Round #429 (Div. 2) 题解(ABCD)
- hdu 1757 A Simple Math Problem
- delphi: reference to(匿名方法)
- 莫烦 tensorflow 笔记 (一)搭建神经网络
- 补一下我曾经拉下的东西——dfs
- ios的app内购研究
- bzoj 1083: [SCOI2005]繁忙的都市 并查集
- java常用代码
- Shiro第四篇【Shiro与Spring整合、快速入门、Shiro过滤器、登陆认证】
- Drools Workbench 7.2.0.Final综合学习-驾照申请案例
- faster rcnn在Ubuntu系统下cpu模式的算法实现