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
Controls derived-class access to base-class members while keeping unrelated client code from accessing them.
How deep it goes
Explains how protected data can break a class invariant and recommends private state with accessors, without detailing all access rules.
Examples
Shows a Student class setting its Person base’s protected age to a negative value, then contrasts private state and validated mutation.
What you can do after
Evaluate inheritance designs and replace vulnerable protected state with private data guarded by accessors and mutators.

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 →

Also covered in

What to know first

Related concepts

Questions about protected member

What is 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.

Which Manning books explain protected member?

Essential TypeScript 5, Third Edition, Python How-To, 100 C++ Mistakes and How to Avoid Them and Kotlin in Action, 2E.

What should I know before learning protected member?

Manning books that teach protected member usually introduce inheritance, encapsulation, class and attribute first.

What is the difference between protected member and private 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. A private member is a program element whose direct access is restricted to its defining class, module, file, or other language-defined scope.

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.