unit UnitMyClass;
来源:互联网 发布:淘宝新品上架看不到 编辑:程序博客网 时间:2024/04/29 11:30
unit UnitMyClass;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;typeTMyClass = Classprivate FField1: integer; FField2: string; FField3: boolean; function GetField3: boolean; procedure SetField3(AField: boolean); public property Field1: integer read FField1 write FField1;published //property Field1: integer read FField1 write FField1; property Field2: string read FField2; property Field3: boolean read GetField3 write SetField3; end;procedure WriteConstObj(const obj:TMyClass);forward;implementationfunction TMyClass.GetField3: boolean; begin //注意这里用FField3而不是Field3. result := FField3; end; procedure TMyClass.SetField3(AField: boolean); begin //注意这里用FField3而不是用Field3,因为Field3是专门供外部使用的。 FField3 := AField; end;procedure WriteConstObj(const obj:TMyClass);begin obj.FField1:=obj.FField1+1;end;end.