Up: Member Keywords   [Contents]


3.1 Access Modifiers

Access modifiers, when provided in keywords, alter the interface into which the definition of member name is placed. There are three interfaces, or levels of visibility, that dictate the context from which a member may be accessed, listed here from the most permissive to the least:

public

Accessible outside of C or any instance of C (e.g. ‘foo.publicProp’). Inherited by subtypes of C.

protected

Not accessible outside of C or an instance of C (e.g. ‘this.protectedProp’ within context of C). Inherited by subtypes of C.

private

Not accessible outside of C or any instance of C. Not inherited by subtypes of C.

KeywordDescription
publicPlaces member name in public interface (accessible outside of C or instance of C; accessible by subtypes). Implied if no other access modifier is provided (but see private);
protectedPlaces member name in protected interface (accessible only within C or instance of C; accessible by subtypes).
privatePlaces member name in private interface (accessible only within C or instance of C; not accessible by subtypes); implicit if the member name is prefixed with an underscore, unless another access modifier is explicitly provided.

Table 3.2: Access modifiers

Access modifiers have the following properties:


Up: Member Keywords   [Contents]