【发布时间】:2011-11-17 13:48:27
【问题描述】:
我尝试以这种方式列出程序:
type
TProc = procedure of object;
TMyClass=class
private
fList:Tlist;
function getItem(index:integer):TProc;
{....}
public
{....}
end;
implementation
{....}
function TMyClass.getItem(index: Integer): TProc;
begin
Result:= TProc(flist[index]);// <--- error is here!
end;
{....}
end.
并得到错误:
E2089 类型转换无效
我该如何解决?
如我所见,我可以制作一个只有一个属性Proc:TProc; 的假类并列出它。但我觉得这是一个不好的方式,不是吗?
PS:项目必须与 delphi-7 兼容。
【问题讨论】:
-
如果您希望代码在 D7 中工作,为什么还要使用 XE。这会让你感到悲伤。