Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-02

"default" visibility for class members

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

xrfang

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"?

Thanks,
Shannon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130227/1cc8dc41/attachment.html>

Reply by email

Sven Barth
to xrfang
xrfang wrote 18 lines
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

Reply by email