不能这样定义。Borland公司的说明:Class and object cannot be declared local to a procedure. program Produce; procedure MyProc; type TMyClass = class Field: Integer; end; begin (*...*) end;begin end.So MyProc tries to declare a class type locally, which is illegal. program Solve; type TMyClass = class Field: Integer; end; procedure MyProc; begin (*...*) end;begin end.The solution is to move out the declaration of the class or object type to the global scope.
没有见过这样定义的,你试一下下面的可以吗? 在窗体或者UNIT里定义类,然后在这里调用。procedure xxx var hhh=T+(类名) ... end; var ... begin .... .....
type
TMyClass = class
Field: Integer;
end;
begin
(*...*)
end;begin
end.So MyProc tries to declare a class type locally, which is illegal. program Solve; type
TMyClass = class
Field: Integer;
end; procedure MyProc;
begin
(*...*)
end;begin
end.The solution is to move out the declaration of the class or object type to the global scope.
在窗体或者UNIT里定义类,然后在这里调用。procedure xxx
var
hhh=T+(类名) ...
end;
var
...
begin ....
.....