Delphi/Lazarus: Difference between restrict, private, and protected Access Modifiers


/ Published in: Delphi
Save to your folder(s)

The difference between private, protected and public is pretty straightforward:

*Private members/methods are only visible within the class that declares them.

*Protected members/methods are visible within the class, and to all subclasses.

*Public members and methods are visible to all other classes.

In Delphi there's a "bug" that makes the visibility of all members public within the same unit. The strict keyword corrects this behaviour, so that private is actually private, even within a single unit. For good encapsulation I would recommend always using the strict keyword.

URL: http://stackoverflow.com/questions/1516493/difference-between-strict-private-and-protected-access-modifiers-in-delphi

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.