CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Delphi >  VCL组件开发及应用

有关CLASS的问题

楼主zhaowei(zxw)2003-03-03 12:40:47 在 Delphi / VCL组件开发及应用 提问

如protected   private   publish   在他们下面声明、定义属性、方法、事件有什么不同啊!构造函数、析构函数的定义生命必须在公共标志下面吗? 问题点数:0、回复次数:6Top

1 楼bluemeteor(挂月||Becoder)回复于 2003-03-03 12:46:30 得分 0

找一本object   pascal的入门书籍来阅读一下吧Top

2 楼huangrenguang(湖)回复于 2003-03-03 12:49:50 得分 0

建议去看看有关面向对象方面的书。Top

3 楼fancier(OP&&C/C++)回复于 2003-03-03 12:50:28 得分 0

//Delphi帮助  
  A   private   member   is   invisible   outside   of   the   unit   or   program   where   its   class   is   declared.   In   other   words,   a   private   method   cannot   be   called   from   another   module,   and   a   private   field   or   property   cannot   be   read   or   written   to   from   another   module.   By   placing   related   class   declarations   in   the   same   module,   you   can   give   the   classes   access   to   one   another抯   private   members   without   making   those   members   more   widely   accessible.  
  A   protected   member   is   visible   anywhere   in   the   module   where   its   class   is   declared   and   from   any   descendant   class,   regardless   of   the   module   where   the   descendant   class   appears.   In   other   words,   a   protected   method   can   be   called,   and   a   protected   field   or   property   read   or   written   to,   from   the   definition   of   any   method   belonging   to   a   class   that   descends   from   the   one   where   the   protected   member   is   declared.   Members   that   are   intended   for   use   only   in   the   implementation   of   derived   classes   are   usually   protected.  
   
  A   public   member   is   visible   wherever   its   class   can   be   referenced.  
   
  Published   members   have   the   same   visibility   as   public   members.   The   difference   is   that   runtime   type   information   (RTTI)   is   generated   for   published   members.   RTTI   allows   an   application   to   query   the   fields   and   properties   of   an   object   dynamically   and   to   locate   its   methods.   RTTI   is   used   to   access   the   values   of   properties   when   saving   and   loading   form   files,   to   display   properties   in   the   Object   Inspector,   and   to   associate   specific   methods   (called   event   handlers)   with   specific   properties   (called   events).  
   
  Published   properties   are   restricted   to   certain   data   types.   Ordinal,   string,   class,   interface,   and   method-pointer   types   can   be   published.   So   can   set   types,   provided   the   upper   and   lower   bounds   of   the   base   type   have   ordinal   values   between   0   and   31.   (In   other   words,   the   set   must   fit   in   a   byte,   word,   or   double   word.)   Any   real   type   except   Real48   can   be   published.   Properties   of   an   array   type   (as   distinct   from    
  array   properties,   discussed   below)   cannot   be   published.  
   
  Some   properties,   although   publishable,   are   not   fully   supported   by   the   streaming   system.   These   include   properties   of   record   types,   array   properties   of   all   publishable   types,   and   properties   of   enumerated   types   that   include   anonymous   values.   If   you   publish   a   property   of   this   kind,   the   Object   Inspector   won抰   display   it   correctly,   nor   will   the   property抯   value   be   preserved   when   objects   are   streamed   to   disk.  
  All   methods   are   publishable,   but   a   class   cannot   publish   two   or   more   overloaded   methods   with   the   same   name.   Fields   can   be   published   only   if   they   are   of   a   class   or   interface   type.  
   
  A   class   cannot   have   published   members   unless   it   is   compiled   in   the   {$M+}   state   or   descends   from   a   class   compiled   in   the   {$M+}   state.   Most   classes   with   published   members   derive   from   TPersistent,   which   is   compiled   in   the   {$M+}   state,   so   it   is   seldom   necessary   to   use   the   $M   directive.  
  //构造函数、析构函数的定义生命必须在公共标志下面吗?  
  是的Top

4 楼netfyee(为了MM努力赚钱)回复于 2003-03-03 12:52:29 得分 0

protected保护的只有在子类等中访问  
   
  private私有的   只能在当前class或当前unit中访问  
   
  publish   是用于发布属性。用于在设计期在inspector中操作的  
   
  构造函数、析构函数的定义生命应该必须在公共标志下面。因为一般都在外部构造,析构   类的实例  
  Top

5 楼vitamin_ok(水水|Eddie(vitamin_ok@mail.csdn.net))回复于 2003-03-03 12:52:37 得分 0

去看看object   pascal的书吧,你的问题,应该都有的!Top

6 楼findcsdn(searchcsdn)回复于 2003-03-03 12:56:40 得分 0

private   的成员只有自己可以访问.  
  protected   相同单元内的其他类和该类的子类可以访问.  
  public     其他类都可以访问。  
   
  构造函数和析构函数的定义因该必须public,因为程序中要用该函数创建实例,如果放在private下面,那么其他程序就看不到该函数,那么这个类就无法初始化,也不可以从该类扩展子类了。   多写写程序,这些概念就会分清了。Top

相关问题

  • 有关JScript .NET的class
  • 有关java2的一个class
  • 有关Inner Class的问题
  • 有关于类(Class)的一个问题。
  • 有关在jsp中找不着bean里的class的问题
  • java编程思想中有关"Class.forName()"和".class"的区别问题
  • 哪里有关于VBS编写Class的技术文章或例子?
  • 今晚最后一个问题,不然睡不瞑目~~~~~有关于CLASS的一个怪问题。
  • Class Properties的用法,一个有关配置文件的修改保存的菜鸟问题
  • C#新手向各位请教了,有关动态调用dll中class相应方法的问题

关键词

  • 函数
  • 子类
  • 构造
  • descends
  • members
  • protected
  • 析构函数的定义
  • 程序
  • module
  • another

得分解答快速导航

  • 帖主:zhaowei

相关链接

  • Delphi类图书
  • Delphi类源码下载
  • Delphi控件下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo