新人请问,怎么获取类成员函数的指针

时间:2021-11-17 19:32:00

新人请教,如何获取类成员函数的指针?
public
  procedure TestAddress;
  procedure ShowAddress;
end;

......


procedure TTest.testAddress;
begin
  ...
end;

procedure TTest.ShowAddress;
var
  P: Pointer;
begin
  P:= @(testAddress);     //这一句报错,variable required
  
end;

请问要怎样获取成员函数的地址?我是新人,请各位前辈指点
TTest = class
public
  procedure TestAddress;
  procedure ShowAddress;
end;

......


procedure TTest.testAddress;
begin
  ...
end;

procedure TTest.ShowAddress;
var
  P: Pointer;
begin
  P:= @(testAddress);     //这一句报错,variable required
  
end;

请问要怎样获取成员函数的地址?我是新人,请各位前辈指点

类 指针


------解决方案--------------------


type
  TPro = procedure of object;
  PPro = ^TPro;
  TTest = class
  public
    procedure TestAddress;
    procedure ShowAddress;
  end;

implementation

  { TTest }

procedure TTest.ShowAddress;
var
  P: Pointer;
  P1: TPro;
begin
  P1 := testAddress;
  P:= @P1;
end;

procedure TTest.TestAddress;
begin

end;

end.