函数指针
/*
type 是定义类型
var 是声明变量
*/
function Abc(i:integer):string;
begin
Result := 'a';
end;
/*定义函数*/
procedure TForm1.btn1Click(Sender: TObject);
type
pfun = function(i:Integer):string; //定义函数指针
var
p:pfun; //声明函数指针变量
begin
p := Abc; //函数的名称就是函数在内存中的地址,也可以说成函数指针。
ShowMessage(p(3));
end;
/*
定义函数指针的格式:
type
pfun = function(i:Integer):string; //有一个type关键字,function后面是没有函数名称的。
*/