Restricting member access to certain parts of code.
Overview
Public members
Protected members
Private members
Constructors and destructors
Inherited members
Overview
All members of a
Type or
Class - including member data, procedures, constants, etc. - belong in one of three different classifications, each with its own rules dictating where in code they may be accessed, or referred to. These rules are called access rights. There are public, protected and private members, and they are declared in a
Type or
Class definition following a
Public,
Protected or
Private label, respectively.
By default, that is, without an access classification label, members of a
Type are public, and members of a
Class are private.
Note: As of 02.26.07, inheritance has not been implemented yet. Thus, protected members are supported as a place-holder of sorts. When talking about member access rights, protected members are identical to private members for the time being.
Public members
Public members can be referred to from anywhere; they are accessible from, for example, member procedures or module-level code or procedures.
Protected members
Protected members can only be accessed from member procedures of the
Type or
Class they are declared in, or member procedures of a derived
Type or
Class. They are not accessible to outside code.
Private members
Private members can only be accessed from member procedures of the
Type or
Class they are declared in. They are not accessible to outside code or member procedures from a derived
Type or
Class.
Constructors and destructors
Constructors and destructors follow the same rules as any other member. When public, objects can be instantiated and destroyed from anywhere in code. When protected, objects can be instantiated and destroyed only from member procedures of their
Type or
Class or a derived
Type or
Class. Private constructors and destructors restrict object instantiation solely to member procedures of their
Type or
Class.
Inherited members
...