All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
六步使用ICallbackEventHandler实现无刷新回调_[Asp.Net教程]
冷静对待流行技术风潮:忽悠一下Ajax_JavaScript技术_编程技术
Delphi append过程在文件的最后追加文本内容
asp.net2.0服务器控件之Label控件
GridView绑定模板格式化日期总结_[Asp.Net教程]
C#中try-catch
用最有效的方式来扩大你网站的名声_JavaScript技术_编程技术
SQL,Server,2008重新创建表的方法_mssql学习_编程技术
FreeTextBox使用方法_[Asp.Net教程]
PHP实例程序:实现给上传图片加水印图案的做法_[PHP教程]
Reading number is top 10 pictures
机器人也有性生活吗?
2012 national geographic daily picture5
More attractive than sora aoi1
黑社会大哥相亲
Terrorist smile the largest human history an explosion2
再来随便发几张
A man's favorite things5
China's first snake village1
避免防盗门的猫眼变成钥匙眼
Summer is most suitable for young people to travel in China8
Download software ranking
Unix video tutorial11
Boxer Classic video1
Sora aoi, the nurse, uniform ,nursing assistant
Detective task-the top secret prostitution files
linux高级编程
apache-tomcat-6.0.33
VC++6.0简体中文版
网页特效实例大全
Prostitutes diary
Sora aoi - one of more PK
aaa published in(发表于) 2014/7/19 0:12:30 Edit(编辑)
delphi类中的属性使用方法

delphi类中的属性使用方法

delphi类中的属性使用方法|实例

属性

可以把属性看成是能对类中的数据进行修改和执行代码的特殊的辅助域。对于组件来说,属性就是列在Object Inspector 窗口的内容。下面的例子定义了一个有属性的简单对象:

TMyObject=class

private

SomeValue:integer;

Procedure SetValue(a:integer);

Public

Property value:integer read SomeValue write SomeValue;

end;

procedure TMyObject. SetValue(a:integer);

begin

if SomeValue<>a then

SomeValue:=a;

end;

TMyObject 是包含下列内容的对象:一个域(被称为SomeValue 的整型数)、一个方法(被称为SetValue 的过程)和一个被称为Value 的属性。SetValue 过程的功能是对SomeValue 域赋值,Value 属性实际上不包含任何数据。Value 是SomeValue 域的辅助域,当想得到Value 中的值时,它就从SomeValue读值;当试图对Value 属性设置值时,Value 就调用SetValue 对SomeValue 设置值。这样做的好处有两个方面:首先,通过一个简单变量就可以使外部代码访问对象的数据,而不需要知道对象的实现细节。

其次,在派生类中可以覆盖诸如SetValue 的方法以实现多态性。

在Object Pascal 中的类实例实际上是指向堆中的类实例数据的32 位指针。当访问对象的域、方法和属性时,编译器会自动产生一些代码来处理这个指针。这时的对象就好像是一个静态变量。所以说,Object Pascal 无法像C++那样在应用程序的数据段中为类分配内存,而只能在堆中分配内存。




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.