[Lazarus] "default" visibility for class members

Sven Barth pascaldragon at googlemail.com
Wed Feb 27 09:04:05 CET 2013


On 27.02.2013 08:40, xrfang wrote:
> Hi All,
>
> My class looks like this:
>
> TMyClass = class
>    FField1: Integer;
> private
>    FField2: string;
> public
>    FField3: string;
> end;
>
> Question is, is FField1 private or public or protected?  For all lcl
> classes,
> I see a lot of fields above "private", it looks like they are same as
> "public",
> because I can access them from outside. But why allow them to be put
> there instead of directly under "public"?

The default visiblity of classes is "public" EXCEPT they are declared 
inside when {$M+} was given or a parent class was declared that way 
(e.g. Classes.TPersistant). In that case the default visiblity is 
"published".

Regards,
Sven





More information about the Lazarus mailing list