.


:




:

































 

 

 

 


(, , ).




: , , . .

(encapsulation ) . , , . , , . .

, .

, - .

 

Delphi ( , , , , ).

 

Delphi ( , , , , ).

 

. - .

Delphi class, , , . .

Type

TInfo = class

FKey: Integer; //

procedure Show; // 1

function GetKey: Integer; // 2

constructor Create; //

destructor Destroy; //

end;

, . , . . , .

. interface, implementation .

, .

:

Var

AMyObject: TInfo; //

A: array [1..10] of TInfo; //

Delphi 32- , . , , . .

. , :

AMyObject:= TInfo.Create;

, . .

constructor TInfo.Create;

Begin

Fkey:= -1;

end;

. , ( ), . ( ). . . , nil, .

, . , -: , , .

, destructor. Destroy ( - , ). , . , TObject.

, .

. .

(property) , . : , /:

Type

TMyClass = class

FKey: Integer;

...

function GetKey: Integer;

procedure SetKey(const Value: Integer);

property Key: Integer read GetKey write SetKey;

...

end;

:

function TMyClass.GetKey: Integer;

Begin

Result:= FKey;

end;

procedure TMyClass.SetKey(const Value: Integer);

Begin

if Fkey <> ANewKey then

Begin

Fkey:= ANewKey;

... //

end;

end;

, , . / , :

Type

TMyClass = class

FKey: Integer;

...

procedure SetKey(const Value: Integer);

property Key: Integer read FKey write SetKey;

...

end;

, :

Type

TMyClass = class

FKey: Integer;

...

property Key: Integer read FKey;

...

end;

.

 





:


: 2016-11-19; !; : 1265 |


:

:

, .
==> ...

1588 - | 1459 -


© 2015-2024 lektsii.org - -

: 0.011 .