Dear Aaron,
This method is currently I use. But I am not happy about that. Because I
want that variable to be logical const, no one should modify it. I want
compiler automatic tell me it is an error if in my code I try to modify the
value.
Thanks any way.
Best Regards
leigh
----- Original Message -----
From: Aaron Scott-Boddendijk <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Saturday, May 06, 2000 2:05 PM
Subject: Re: [DUG]: Declare const object
> You can't declare it like that I'm afraid...
>
> the best you could probably do would be
>
> unit X;
>
> interface
>
> TMyClass = class(TObject)
> public
> AValue :Integer;
> constructor Create(AValue :Integer);
> end;
>
> var
> MyClass :TMyClass;
>
> implementation
>
> constructor TMyClass.Create(AValue :Integer);
> begin
> inherited Create;
> Self.AValue := AValue;
> end;
>
> initialization
> MyClass := TMYClass.Create(0);
> finalization
> MyClass.Free;
> end;
>
> I tend towards data-driven code a lot and rather than consts I use file,
registry,
> resource, db or remote sources for the initialisation values of my
structures... Of
> course sometimes you just want a const ;)
>
> --
> Aaron@home
>
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz