unit UnitMyClass;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyClass = Class
private
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;
implementation
function 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.