Name
Private Directive
Syntax
typeClass declarationprivateField declarations...Property and method declarations... end;
Description
The private directive introduces the private
section of a class declaration. Private fields,
methods, and properties are not accessible by other classes and
subroutines, except in the same unit.
Tips and Tricks
Declare all fields as private, and declare properties to access the fields at higher access levels: protected, public, or published. That gives you the flexibility to change the way a field is accessed, say by changing a direct field reference to a method reference. Such changes affect only the implementation of the class, and not its use.
The
privatedirective prevents you from calling the method directly, but the class might have other ways to call the method. The private method can be a message handler, support a public property, or implement an interface’s method.
Example
See the class keyword for an example.
See Also
| Class Keyword, Protected Directive, Public Directive, Published Directive |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access