组件制作之一(概念)[2]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 linzhengqun 的 blog

     tsomeobj=class

          private

            fcount:integer;

          protected

            procedure setcount(value:integer);

          published

       property count:integer read fcount write setcount default 0;//属性定义

          end;

    该属性从私有成员fcount读出值,而靠setcount方法设置值到私有成员fcount

属性的优势在于可以很直观进行读写,而又不同于私有成员。因为属性可以通过写访问方法来保护私有成员:

     procedure tsomeboj.setcount(value:integer);

          begin

             if fcount<>value then

                 fcount:=value;

          end;

本文关键:组件制作之一(概念)
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top