liveBook · Manning

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.

How 4 Manning books explain it

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.

Read how Python How-To explains protected member →

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.

Read how Kotlin in Action, 2E explains protected member →

Related concepts

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.