Protected member
A protected member is a class attribute or method accessible within its defining class and, subject to language rules, within subclasses or other related contexts.
Essential TypeScript 5, Third Edition
An access control keyword specifies which code can access a class member or other program element.
- How it is used
- Lets subclasses use inherited properties while restricting direct access from other code.
- How deep it goes
- Defines the access rule and applies it to collection properties, while warning that enforcement stops at compilation.
- Examples
- Shows a protected todo-item map used for JSON persistence and a protected array used by a searchable generic collection.
- What you can do after
- Apply it via TypeScript to share class members with subclasses without declaring them public.
Read how Essential TypeScript 5, Third Edition explains protected member →
Python How-To
Protected access is an access level in which a class attribute or method is available to the defining class and its subclasses but not external code.
- How it is used
- Uses a naming convention to communicate which class members belong to implementation details rather than the public interface.
- How deep it goes
- Defines protected access, demonstrates subclass inheritance, and stops short of formal enforcement because Python has no protected keyword.
- Examples
- Uses Task note formatting, Employee vacation requests, Supervisor inheritance, and a protected _urgency backing attribute.
- What you can do after
- Apply it via Python's single-underscore convention to signal subclass-accessible implementation members and shape clearer class interfaces.
100 C++ Mistakes and How to Avoid Them
A protected member is a class member accessible from the class and its derived classes, subject to C++ access rules, but not generally from unrelated client code.
- How it is used
- Uses protected members to give derived classes direct access while examining the resulting class-invariant risk.
- How deep it goes
- Explains access, validation bypass, and invariant maintenance through code, but does not develop language internals.
- Examples
- Uses Person and Student classes, an invalid negative age, and private-member replacement code.
- What you can do after
- Apply private state and validated accessors to reduce invariant violations when maintaining inheritance hierarchies.
Read how 100 C++ Mistakes and How to Avoid Them explains protected member →
Kotlin in Action, 2E
The protected modifier restricts access to a declaration to its containing class and subclasses in Kotlin.
- How it is used
- Restricts class-member access to the declaring class and subclasses while preventing same-package access.
- How deep it goes
- Defines the visibility rule, demonstrates an extension-function failure, and contrasts Kotlin with Java package behavior.
- Examples
- Uses TalkativeButton, its protected whisper function, a subclass call, and an extension-function access error.
- What you can do after
- Apply it via Kotlin visibility modifiers to expose implementation details to subclasses while blocking unrelated callers.
Related concepts
- private membercontrasts with · A private member is a program element whose direct access is restricted to its defining class, module, file, or other language-defined scope.
- leading underscore conventionconfigured by · The leading underscore convention prefixes an identifier with an underscore to signal intended internal or non-public use without enforcing access restrictions.
- inheritanceused by · Inheritance is a mechanism by which a child type or element receives properties, values, or behavior from a parent, subject to system rules and possible overrides.
- invariantcontrasts with · An invariant is a property or condition that remains true across the valid states, operations, or specified transformations of a system or computation.
- instance variableproduces · An instance variable is data associated with a particular object, rather than shared across all instances of its class or type.
- selfuses · self is Ruby's implicit reference to the object that is the current method-execution receiver.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.



