【发布时间】:2012-05-05 08:29:47
【问题描述】:
在 Lazarus / delphi 中有一些技巧如何获取成员函数的指针吗?
我有这段无法编译的代码....
错误是
在德尔福:variable required
在拉撒路:Error: Incompatible types: got "<procedure variable type of function(Byte):LongInt of object;StdCall>" expected "Pointer"
代码:
TClassA = class
public
function ImportantFunc(AParameter: byte): integer; stdcall;
end;
TClassB = class
public
ObjectA: TClassA;
ImportantPtr: pointer;
procedure WorkerFunc;
end;
function TClassA.ImportantFunc(AParameter: byte): integer; stdcall;
begin
// some important stuff
end;
procedure TClassB.WorkerFunc;
begin
ImportantPtr := @ObjectA.ImportantFunc; // <-- ERROR HERE
end;
谢谢!
【问题讨论】:
标签: delphi function pointers lazarus