[Lazarus] How to access private field in FPC 2.7.1? ("class helper?")

Sven Barth pascaldragon at googlemail.com
Fri Dec 23 20:08:15 CET 2011


On 23.12.2011 20:04, silvioprog wrote:
> Hi,
>
> I tried to access the FScanner field from the TJSONParser, but without
> sucess. x(
>
[snip]

> The error:
>
> Error: identifier idents no member "FScanner".
>
> So, FPC 2.7.1 support this sintaxe?:
> http://stackoverflow.com/questions/8330003/access-a-strict-protected-property-of-a-delphi-class
>
> In FPC 2.4.4 I use only:
>
>    TJSONParserHelper = class(TJSONParser)
>    public
>      property Scanner: TJSONParser read FScanner;
>    end;
>
> Thanks.
>

Your code is principially correct, but your assumption is not: you can 
not access (strict) private fields using a class helper. Only (strict) 
protected, public and published are supported (this is the same in 
Delphi btw.).

Regards,
Sven




More information about the Lazarus mailing list