[fpc-devel] private visibility question

Martin Frb lazarus at mfriebe.de
Mon Sep 28 11:20:11 CEST 2026


my fault...

the procedure needed to be public.

On 28/09/2026 11:18, Martin Frb via fpc-devel wrote:
> If I have the below TFoo, and in ANOTHER unit I declare
> var   foo: TFoo
>
> then I can access
>   foo.e := a1;
>
> This works even though "a1" is private and not visible. But by being 
> the type for a public field (or method) it becomes available.
>
> This is not true for
>   foo.b.abc;
>
>
> Is that intentional?
>
>
>
>
> unit Unit2;
> {$mode ObjFPC}{$H+}
> interface
> uses   SysUtils;
> type
>   TFoo = class
>   private type
>     TEnum = (a1,a2);
>
>     TBar = class
>       protected
>         procedure abc; virtual ; abstract;
>     end;
>
> public
>   b: TBar;
>   e: TEnum;
> end;
>
> implementation
>
> end.
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel



More information about the fpc-devel mailing list