.


:




:

































 

 

 

 





 

(constructor) (Destructor). Delphi Create() Destroy(). Create ( ), Destroy() .

 

Type

TMyClass= class

FIntField: Integer;

Constructor Create(Value:Integer);

Destructor Destroy;

End;

, , , .

Var

MyObject: TMyClass;

Begin

MyObject.FIntField:= 0; //.

// ,

MyObject:= TMyClass.Create; //.

MyObject.FIntField:= 0; //

 

MyObject.Free; //

End;

TObject Free, Destroy.

If Self<>Nil then Destroy;

self .

System FreeAndNil, ,

Nil.

FreeAndNil(MyObject);

, . inherited()

Constructor TMyClass.Create(AOwner:TComponent;Value:integer);

//

Begin

Inherited Crete(Aowner:TComponent);//

intField:=Value;//

End;

 

, . , .

Overload.

Type

T1=class(TObject)

Procedure Sum(X,Y:Integer);overload;

End;

T2=class(T1)

Procedure Sum(X,Y:Real);overload;

End;

Var Ct:T2;

Begin

Ct:=T2.Creat;

Ct.Sum(2,2); // T1.sum()

Ct.Sum(2.0,2.0);// T2.sum()

End;

reintroduce.

Type

T1=class(TObject)

Procedure Sum(X,Y:Integer);overload; virtual;

End;

T2=class(T1)

Procedure Sum(X,Y:Real);reintroduce; overload;

End;

. , class.

Type

TMyclass=class(TObject)

Class Function GetClassName:String;

End;

Var

S:String;

Begin

S:=TMyClass.GetClassName;

End;

, . Property, read write( read write ). , .

 

Type

TaClass=Class

IntField:Integer;

Function GetField:integer;

Procedure SetField(Value:integer);

Property IntegrValue:integer read GetField write SetFeild;

End;

. ,

var

aclass:Taclass;

Value:integer;

Begin

Aclass:= Taclass.Create;//

//

Aclass.IntegerValue:=0;

Value:= aclass.IntegerValue;

Aclass.Destroy;//

End;

, , write read.

, published (), private (), protected (), public (), automated ().

, .

. public , . published , . private , , , . Protected .

Type

TForm = class (TForm)

Button1:Tbutton;//

Private //

FintField:integer;

Procedure SetValue(Value:Integer);

FunctionGetValue:integer;

Published //

Property intField read GetValue write SetValue

Protected //

//

Procedure Proc1;

Public //

Procedure Proc2;

End;





:


: 2016-10-07; !; : 596 |


:

:

- , 20 40 . - .
==> ...

1600 - | 1559 -


© 2015-2024 lektsii.org - -

: 0.011 .