TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;我查了说delphi中如果类成员不加权限说明就是private的
Button1: TButton;
procedure Button1Click(Sender: TObject);
没有加权限说明,应该是和在private中效果是一样的吧,可是我把它们剪贴到private中提示出错了,找不到这两个成员了。
我在图书馆随便借了本DELPHI的书,那书挺烂的,上面也没写。
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;我查了说delphi中如果类成员不加权限说明就是private的
Button1: TButton;
procedure Button1Click(Sender: TObject);
没有加权限说明,应该是和在private中效果是一样的吧,可是我把它们剪贴到private中提示出错了,找不到这两个成员了。
我在图书馆随便借了本DELPHI的书,那书挺烂的,上面也没写。
解决方案 »
- 【求助】关于IE用的ACTIVEX
- 问个发送短信的问题
- 哪里有反编译软件dede 3.50的使用说明?
- 急,有关SQL SERVER 2000数据移出问题!
- 请教多表数据查询合并!这个内容更加详细,谢谢大家!
- 请问如何识别操作系统语言并得到返回值!!请教高手!
- Rave Reports,在哪儿?
- 用户按下回车键,即执行"确定"按钮的click事件,该怎么做?
- 如何判断一个表中几个字段中的最大值
- 初学三层结构
- alphacontrols 皮肤,当最小化到托盘的时候,还原窗口后,只有一个窗口的皮肤有效,别的窗体效果全没了
- 急啊 求rava 报表高手帮忙看下 关于图片动态调入(从文件夹下)的问题 多页如何随数据库记录变化而变化 一页的已经解决
Visibility of class members
[code]
...
If a member's declaration appears without its own visibility specifier, the member has the same visibility as the one that precedes it. Members at the beginning of a class declaration that don't have a specified visibility are by default published, provided the class is compiled in the {$M+} state or is derived from a class compiled in the {$M+} state; otherwise, such members are public.
...
[/code]VCL 控件类型离 TObject 最近的是 TPersistent,再注意 Classes 单元里它的声明:{$M+} TPersistent = class(TObject)
...
end;{$M-}由于 TForm1 继承自 TPersistent,后者的默认可见域是 published,所以 TForm1 的默认域也是 published
TMyClass = class(TControl)
private
... { private declarations here}
protected
... { protected declarations here }
public
... { public declarations here }
published
... { published declarations here }
end;You can increase the visibility of a member in a descendant class by redeclaring it, but you cannot decrease its visibility. For example, a protected property can be made public in a descendant, but not private. Moreover, published members cannot become public in a descendant class. For more information, see Property overrides and redeclarations.
类默认的封装等级是 published Members at the beginning of a class declaration that don't have a specified visibility are by default published
不过我个人不写不带访问声明的代码,为何不让代码清晰些?
Members at the beginning of a class declaration that don't have a specified visibility are by default published, provided the class is compiled in the {$M+} state or is derived from a class compiled in the {$M+} state
而加了{$M+}之后默认是Published.
所以自TPersistent派生的都是Published.除非某个派生类加了{$M-}