A
Apollo_BD
Unregistered / Unconfirmed
GUEST, unregistred user!
不明白"全局过程指针"和"方法指针"到底有什么区别?
能否给个例子,我写代码为什么通不过去
func:=Myfunc.showfunc;//此句编译通不过!不知道错在那里?请高手指点!
代码如下:
Type
......
TMyfunc=class
public
function showfunc(S:string):boolean;
End;
Tfunc=Function (name:string):boolean
//全局过程指针
TfunObject=Function (name:string):boolean of object
//方法指针
var
.....
implementation
function TMyfunc.showfunc(S: string): boolean;
begin
Showmessage(s);
Result:=True;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
myfunc:Tmyfunc;
func:Tfunc;
funobject:Tfunobject;
begin
Myfunc:=Tmyfunc.Create;
func:=Myfunc.showfunc;//此句编译通不过!
func('Test Tfunc');
end;
end.
能否给个例子,我写代码为什么通不过去
func:=Myfunc.showfunc;//此句编译通不过!不知道错在那里?请高手指点!
代码如下:
Type
......
TMyfunc=class
public
function showfunc(S:string):boolean;
End;
Tfunc=Function (name:string):boolean
//全局过程指针
TfunObject=Function (name:string):boolean of object
//方法指针
var
.....
implementation
function TMyfunc.showfunc(S: string): boolean;
begin
Showmessage(s);
Result:=True;
end;
procedure TForm2.Button1Click(Sender: TObject);
var
myfunc:Tmyfunc;
func:Tfunc;
funobject:Tfunobject;
begin
Myfunc:=Tmyfunc.Create;
func:=Myfunc.showfunc;//此句编译通不过!
func('Test Tfunc');
end;
end.