新人请教,如何获取类成员函数的指针?
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.

相关文章:

  • 2022-02-13
  • 2021-07-06
  • 2022-12-23
  • 2021-10-01
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-28
  • 2022-12-23
  • 2022-01-02
  • 2021-09-24
  • 2021-06-26
  • 2022-12-23
相关资源
相似解决方案