我不明白为什么以下小型控制台应用程序无法编译:
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.
答案 0 :(得分:11)
您必须添加括号以表明您正在调用该程序;即,
myRec.Proc();