[英]Using Delphi, unable to use anonymus type as a type of a record?
I don't understand why the following small console application does not compile: 我不明白为什么以下小型控制台应用程序无法编译:
program Project1;
type
TProc = reference to procedure;
TMyRec = record
Proc: TProc;
end;
var
myProc: TProc;
myRec: TMyRec;
begin
myProc := procedure begin writeln; end;
myProc; // compiles fine
myRec.Proc := procedure begin writeln; end;
myRec.Proc; //E2014 Statement exptected, but expression of type 'TProc' found
end.
You must add parenthesis to indicate that you're calling the procedure; 您必须添加括号以表示您正在调用该过程; ie, 即
myRec.Proc();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.