为何不能在 Published 中定义 , 而在 Public 中可以 ?(50分)

  • 主题发起人 主题发起人 pcgod
  • 开始时间 开始时间
P

pcgod

Unregistered / Unconfirmed
GUEST, unregistred user!
type
TForm3 = class(TForm)
Button1: TButton;
i : Integer ; //
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
k : Integer ;
end;

保存时就提示删掉 i 的定义 ,编译提示 :
[Error] Unit3.pas(12): Published field 'i' not a class nor interface type
请问为什么 ? 这两种接口有什么不同 ? 谢谢
 
Object Pascal 就是这么规定的,不能把非class和inteface
类型的Field(字段) Published出来.
Published和Punlic 成员可见性完全相同,它们的区别在于Published
成员有RTTI信息,而Public没有.
 
谢谢,您能否稍微详细讲讲 ? 谢谢
 
,不能把非class和inteface类型的Field(字段) Published出来. ---- 为什么要做这样的规定 ?
RTTI信息 指什么 ?

谢谢



 
1. 只能猜想了,估计是不想让内部数据直接暴露在外面。
2. RTTI 是Run Time Type Information的缩写,可以在运行的时候获得一个
对象的某些特性。
 
多人接受答案了。
 
后退
顶部