[fpc-pascal] TObject
Joao Morais
post at joaomorais.com.br
Tue Nov 4 11:38:46 CET 2008
Carsten Bager wrote:
>> Here the Data getter is called, ie, hSafeVar, because you are reading a
>> value from it.
>>
>> Use a function as a getter instead of a class member. Btw getters and
>> setters have not the same syntax, you need to create two different methods.
>
> Was it this you meant? Now I cannot compile. If I change rSafeVar (In the
> property declaration) to hSafeVar it compiles.
>
> [...]
>
> TSafeVar=class(TObject)
> Private
> hSafeVar:SafeVar_typ;
> Procedure wSafeVar(data:SafeVar_typ);
> Function rSafeVar(data:SafeVar_typ):SafeVar_typ;
Change to
Function rSafeVar: SafeVar_typ;
--
Joao Morais
> Public
> constructor create;
> destructor destroy; override;
> property data:SafeVar_typ read rSafeVar write wSafeVar;
> Published
> end;
>
>
>
> var
> SafeVar:TSafeVar;
>
> constructor TSafeVar.create;
> Begin
> inherited Create;
> fillchar(hSafeVar,sizeof(SafeVar_typ),chr(0));
> End;
>
> destructor TSafeVar.destroy;
> Begin
> inherited destroy;
> End;
>
> Procedure TSafeVar.wSafeVar(data:SafeVar_typ);
> Begin
> WriteLn('Write');
> End;
>
> Function TSafeVar.rSafeVar(data:SafeVar_typ):SafeVar_typ;
> Begin
> WriteLn('Read');
> End;
>
> Begin
> SafeVar:=TSafeVar.create;
> SafeVar.data.week:=1;
> SafeVar.free;
> End.
> Med venlig hilsen
> Carsten Bager
>
> BEAS A/S
> Brørupvænget 10
> DK-7650 Bøvlingbjerg
> Tlf. : +45 9788 5222 Fax : +45 9788 5434
> www.beas.dk
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
More information about the fpc-pascal
mailing list