类型转换我尝试做的程序列表中这样说:
问题与德尔福XE
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 Invalid typecast
我怎样才能解决这个问题? 正如我所看到的,我只能通过一个属性Proc:TProc;
制作假类并列出它。但我觉得这是一种糟糕的方式,不是吗?
PS:项目必须与delphi-7兼容。
如果您希望代码在D7中工作,您为什么使用XE?那会导致你的悲伤。 –