Inheritance
Inheritance is a mechanism in which a derived type or descendant element receives properties or behavior from a parent, subject to rules that may allow specialization or overriding.
Python Workout: 50 ten-minute exercises
Inheritance is an object-oriented technique in which a class derives functionality from an existing parent class and can add or modify that functionality.
- How it is used
- Uses inheritance to organize related Python classes, reuse shared behavior, and add or modify specialized functionality.
- How deep it goes
- Traces attribute lookup through instances, classes, parents, and object, then applies super and subclass-specific class attributes.
- Examples
- Demonstrates Person and Employee, Foo and Bar, Bowl and BigBowl, FlexibleDict, and animal class hierarchies.
- What you can do after
- Build it from scratch by defining parent and child classes, reusing methods, overriding behavior, and delegating initialization with super.
Read how Python Workout: 50 ten-minute exercises explains inheritance →
Python Workout, Second Edition
Inheritance is the Python class relationship in which a derived class receives attributes and behavior from one or more base classes.
- How it is used
- Uses inheritance to organize related Python classes, reuse parent behavior, and add or modify subclass functionality.
- How deep it goes
- Traces attribute lookup through instances, classes, parents, and object, then applies inheritance through exercises and overrides.
- Examples
- Uses Person and Employee, Foo and Bar, Bowl and BigBowl, Animal subclasses, and dict extensions as implementation exercises.
- What you can do after
- Build it from scratch by defining subclasses, reusing parent initialization with super, overriding methods, and extending built-in classes.
Read how Python Workout, Second Edition explains inheritance →
100 C++ Mistakes and How to Avoid Them
Inheritance is a C++ language mechanism by which a derived class acquires and can extend members and behavior from base classes.
- How it is used
- Uses public inheritance to model substitutable related classes rather than reuse code alone.
- How deep it goes
- Explains design and correctness mistakes with corrected implementations, while leaving protected, private, and virtual inheritance outside the is-a discussion.
- Examples
- Contrasts square-rectangle substitution with a Shape interface and repairs Student copy assignment and polymorphic Shape destruction.
- What you can do after
- Evaluate inheritance relationships and diagnose invariant, assignment, and destruction mistakes in class hierarchies.
Read how 100 C++ Mistakes and How to Avoid Them explains inheritance →
The Quick Python Book, Fourth Edition
Inheritance is an object-oriented mechanism by which a class derives behavior and structure from another class, forming a hierarchy of related classes.
- How it is used
- Uses inheritance to share behavior across related classes and customize built-in types and exceptions.
- How deep it goes
- Explains subclass syntax, initialization, method lookup, attribute shadowing, type checks, and selected built-in subclassing caveats.
- Examples
- Uses shape classes, an HTML element hierarchy, custom exceptions, and typed list and dictionary exercises.
- What you can do after
- Builds Python subclasses that reuse base initialization and methods, specialize behavior, and organize exceptions.
Read how The Quick Python Book, Fourth Edition explains inheritance →
Practices of the Python Pro
Inheritance is an object-oriented mechanism by which a class derives or reuses behavior and structure from one or more other classes.
- How it is used
- Uses inheritance to model true is-a relationships and specialize behavior, while reserving composition for has-a relationships and reusable behavior.
- How deep it goes
- Explains hierarchy risks, design rules, Python inspection, multiple inheritance, method resolution order, and abstract base classes.
- Examples
- Demonstrates inheritance with bicycle components, bird subclasses, command classes, mixins, and contrasting hierarchy diagrams.
- What you can do after
- Apply inheritance selectively, specialize superclass behavior, combine it with composition, and inspect or test Python hierarchies.
The Well-Grounded Python Developer: How the pros use Python and Flask
Inheritance is an object-oriented programming mechanism in which a class derives attributes and behavior from another class.
- How it is used
- Uses inheritance to share shape attributes and behavior while letting individual shapes define their own features.
- How deep it goes
- Explains parent–child terminology and Python declaration syntax, then develops constructors and drawing methods through a shape hierarchy.
- Examples
- Builds on screen-drawn rectangles, squares, and circles, including a square initialized through its rectangle parent.
- What you can do after
- Build it from scratch by defining Python subclasses that reuse parent initialization and add shape-specific behavior.
Object-Oriented Software Design in C++
Inheritance is a language mechanism by which a subclass derives state and behavior from a superclass and may extend or override them.
- How it is used
- Models is-a relationships and structures reusable object-oriented designs before choosing between inheritance and composition.
- How deep it goes
- Defines superclass inheritance, subclass extension, and overriding, then examines duplication, hardcoded behavior, and Template Method trade-offs.
- Examples
- Uses Book subclasses, Toy subclasses, UML generalization diagrams, and configurable play and sound behavior classes.
- What you can do after
- Evaluate inheritance designs, identify duplication and hardcoded behavior, and refactor variable behavior toward composition in C++.
Read how Object-Oriented Software Design in C++ explains inheritance →
Web Components in Action
- How it is used
- Connects familiar DOM elements to HTMLElement and shows how subclasses can share component behavior.
- How deep it goes
- Defines inheritance through an animal analogy, then demonstrates DOM class relationships, component subclassing, and CSS custom-property inheritance.
- Examples
- Uses animal classes, familiar DOM elements, a frame-updating countdown component, and scoped text-color variables.
- What you can do after
- Build component subclasses that reuse a base class’s frame-update behavior and customize its update method.
Essential TypeScript 5, Third Edition
Class inheritance is a mechanism by which one class derives features from a superclass.
- How it is used
- Uses inheritance to share class features while specializing subclasses and to examine how TypeScript types collections of related objects.
- How deep it goes
- Works through prototype lookup, superclass construction, method overrides, and subclass-array inference, including a failed inference assumption and an explicit annotation.
- Examples
- Uses a taxed product overriding `toString` and employee, customer, and supplier subclasses placed in a typed array.
- What you can do after
- Build it from scratch with `extends` and `super`, then annotate a shared-superclass array when inference yields a narrower union.
Read how Essential TypeScript 5, Third Edition explains inheritance →
The Well-Grounded Rubyist, Fourth Edition
Class inheritance is the Ruby mechanism by which a class derives behavior and structure from another class.
- How it is used
- Uses superclass–subclass relationships to share instance methods and model more specific kinds of objects.
- How deep it goes
- Explains declaration syntax, inherited methods, ancestry, single inheritance, and method lookup; leaves fuller module treatment beyond the initial class hierarchy.
- Examples
- Shows Publication, Magazine, and Ezine sharing attributes, then contrasts a CargoHold subclass with a module-based design.
- What you can do after
- Build it from scratch with `<`, then evaluate whether a superclass or module better supplies shared behavior.
Read how The Well-Grounded Rubyist, Fourth Edition explains inheritance →
Python How-To
Class inheritance is a Python object-model feature in which a class derives attributes and behavior from one or more other classes.
- How it is used
- Organizes related data models around shared implementations while keeping role-specific behavior in subclasses.
- How deep it goes
- Explains subclass creation, inherited initialization and methods, dataclass field ordering, and inheritance-aware type checks.
- Examples
- Uses employee roles, inherited bill fields, and exact-versus-inherited type comparisons.
- What you can do after
- Build it from scratch to share class behavior and create specialized subclasses, while weighing hierarchy complexity.
Software Design for Python Programmers
Inheritance is an object-oriented mechanism through which a subclass derives state and behavior from a superclass.
- How it is used
- Uses inheritance to organize shared state and behavior while evaluating whether subclass hierarchies improve application design.
- How deep it goes
- Defines superclass and subclass inheritance, then examines duplication, hardcoding, overriding, composition, and design-pattern tradeoffs.
- Examples
- Demonstrates inheritance with book-catalogue classes, toy subclasses, and sports subclasses for players and venues.
- What you can do after
- Evaluate inheritance against composition and select a hierarchy or pattern that limits duplication, coupling, and hardcoded behavior.
Read how Software Design for Python Programmers explains inheritance →
Secrets of the JavaScript Ninja, Second Edition
A reuse relationship in which one object or type can access properties or behavior defined by another through a hierarchical relationship.
- How it is used
- Uses inheritance to reuse object properties and methods without repeating code or data.
- How deep it goes
- Works through prototype lookup, failed method copying, constructor-chain setup, and ES6 syntax, including the older approach’s constructor-property repair.
- Examples
- Contrasts copied dance methods with a prototype chain, then checks Person and Ninja instances created with ES6 classes.
- What you can do after
- Build it from scratch with constructor prototypes or apply it via ES6 extends and super, then check the relationship with instanceof.
Read how Secrets of the JavaScript Ninja, Second Edition explains inheritance →
CSS in Depth, Second Edition
An inherited property is a CSS property whose value is passed from an element to its descendants when they do not have their own cascaded value.
- How it is used
- Uses inheritance to share styles across descendants while distinguishing inherited values from values assigned by the cascade.
- How deep it goes
- Explains which properties commonly inherit, how overrides work, and how keywords alter the result, without attempting a comprehensive property list.
- Examples
- Uses a body font, a gray footer link, a font shorthand conflict, and panels inside different color contexts.
- What you can do after
- Diagnose/debug with inheritance by tracing parent values, descendant overrides, and shorthand declarations; apply `inherit` when a link should follow its parent.
Read how CSS in Depth, Second Edition explains inheritance →
Data-Oriented Programming: Reduce software complexity
Class inheritance is a language mechanism in which a class derives behavior and structure from one or more parent classes.
- How it is used
- Uses parent classes to reuse common behavior and structure in object-oriented system designs.
- How deep it goes
- Explains inheritance through UML notation and a changing library requirement, but stops short of implementation details.
- Examples
- Uses User, Member, Librarian, VIPMember, login behavior, and adding book items as concrete design examples.
- What you can do after
- Evaluate how a new requirement may increase class-hierarchy complexity when behavior is locked inside methods.
Read how Data-Oriented Programming: Reduce software complexity explains inheritance →
Web Design Playground, Second Edition
CSS inheritance is the propagation of certain computed property values from a parent element to its child and descendant elements.
- How it is used
- Explains how parent styles reach descendants while teaching CSS style behavior alongside cascading and specificity.
- How deep it goes
- Defines propagation for selected properties, shows nested inheritance, and notes exceptions such as borders and links.
- Examples
- Uses a styled intro div with nested elements and a body-header-h1 em-size chain.
- What you can do after
- Understand how selected parent styles affect descendants and why some properties, such as borders, do not transfer.
Read how Web Design Playground, Second Edition explains inheritance →
Web Design Playground
- How it is used
- Uses inherited CSS properties to carry styles from parents to descendants without separate rules for each element.
- How deep it goes
- Defines inheritance, contrasts inherited text styles with borders, and works through relative font sizes; defers the complete property list to the W3C.
- Examples
- Demonstrates a brown 1.1em div with nested elements and calculates font sizes across body, header, and h1.
- What you can do after
- Apply it via CSS rules to style descendants and anticipate noninherited borders, browser link colors, and nested font sizes.
Math for Web Design
CSS inheritance is the mechanism by which certain property values are passed from an element to its descendants unless overridden.
- How it is used
- Explains unexpected CSS sizes by tracing property values through parent and descendant elements.
- How deep it goes
- Works through inherited and non-inherited properties, compounding em sizes, computed values, percentages, and unitless line-height.
- Examples
- Calculates two nested heading sizes and contrasts percentage with unitless line-height on a parent and child.
- What you can do after
- Diagnose/debug unexpected heading and line-height sizes, then apply rem or unitless line-height to avoid the illustrated problems.
Kotlin in Action, 2E
Inheritance is the language mechanism by which a class derives members and behavior from a superclass.
- How it is used
- Uses inheritance to define controlled Kotlin class hierarchies while protecting members not intended for extension.
- How deep it goes
- Explains open, final, override, and abstract members with examples, stopping short of broader inheritance design guidance.
- Examples
- Uses Clickable, Button, RichButton, ThemedButton, and conflicting default interface methods to demonstrate inheritance behavior.
- What you can do after
- Apply it via Kotlin's open, override, final, and abstract modifiers to build selectively extensible class hierarchies.
Clojure: The Essential Reference
Concrete inheritance is an object-oriented mechanism in which a concrete class inherits implementation from another concrete class.
- How it is used
- Positions concrete inheritance as a Java-interoperability concern while rejecting it in Clojure's object-oriented model.
- How deep it goes
- Contrasts Clojure's prohibition with Java-oriented extension points but stops short of inheritance mechanics or dispatch internals.
- Examples
- Uses gen-class, proxy, reify, deftype, defrecord, and defprotocol as contrasting type and polymorphism mechanisms.
- What you can do after
- Evaluate whether Java class extension, records, or protocol-based dispatch fits a Clojure design.
Read how Clojure: The Essential Reference explains inheritance →
Grokking Software Architecture
Inheritance is an object-oriented language feature that allows a new class to acquire properties and methods from an existing class.
- How it is used
- Uses inheritance to share class features and help model systems that must accommodate new types.
- How deep it goes
- Defines inheritance and illustrates it with app and patient examples, without detailing implementation mechanics.
- Examples
- Illustrates inherited app icons and names, plus a hospital TreatmentRoom that accommodates different patient types.
- What you can do after
- Understand how classes can inherit shared features and add specialized ones.
Read how Grokking Software Architecture explains inheritance →
The Joy of JavaScript
A code-reuse relationship in which one object or construct acquires or specializes behavior and data from another.
- How it is used
- Uses inheritance to model specialized transaction objects while comparing prototype, class, and module-based reuse.
- How deep it goes
- Traces prototype links, constructor calls, property lookup, encapsulation, and prototype pollution through worked JavaScript examples.
- Examples
- Uses Transaction and HashTransaction implementations, prototype listings, util.inherits, private fee fields, and module-pattern construction.
- What you can do after
- Builds inheritance with constructor functions or class and extends, and evaluates tradeoffs involving boilerplate, sharing, and encapsulation.
Secrets of the JavaScript Ninja, Third Edition
Inheritance is the behavior by which a JavaScript object obtains accessible properties from its prototype chain, including both data properties and methods.
- How it is used
- Supports code reuse by extending object features, while prototypes underpin class-based inheritance.
- How deep it goes
- Explains prototype-chain lookup and class inheritance mechanics, including constructors and super, and notes the absence of multiple inheritance.
- Examples
- Uses linked Yoshi, Hattori, and Kuma objects, plus Person and Ninja classes.
- What you can do after
- Apply inheritance with Object.setPrototypeOf or class extends, and check property access with in and instanceof.
Read how Secrets of the JavaScript Ninja, Third Edition explains inheritance →
Also covered in
- Learn C++ by Example
- Pro Angular 16
- 100 Java Mistakes and How to Avoid Them
- Learn Go with Pocket-Sized Projects
- Go in Action, Second Edition
- Tiny CSS Projects
- Java Persistence with Spring Data and Hibernate epub
- Idiomatic Rust
- Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
- Go by Example
- JavaScript in DepthIn early access (MEAP)
What to know first
- objectAn object is a distinct entity represented or manipulated within a computational system, typically as a value, data structure, resource, or instance of a type.
- classA class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
- attributeAn attribute is a named property or piece of information associated with an entity, object, or structured data item.
- superclassA superclass is a class from which another class inherits members, structure, or behavior.
Related concepts
- compositioncontrasts with · Composition is the construction of a larger behavior, computation, or system by combining smaller functions, components, or operations.
- object-oriented programmingpart of · Object-oriented programming is a programming paradigm that organizes software around objects combining state and behavior, often using encapsulation, classes, inheritance, or polymorphism.
- inheriteduses · inherited is a Ruby class method callback invoked on a class when that class is subclassed, receiving the new subclass as its argument.
- public inheritanceincludes · Public inheritance is C++ inheritance in which the public and protected members of a base class retain their corresponding accessibility in the derived class.
- classkind of · A class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
Questions about inheritance
What is inheritance?
Inheritance is a mechanism in which a derived type or descendant element receives properties or behavior from a parent, subject to rules that may allow specialization or overriding.
Which Manning books explain inheritance?
Python Workout: 50 ten-minute exercises, Python Workout, Second Edition, 100 C++ Mistakes and How to Avoid Them, The Quick Python Book, Fourth Edition, Practices of the Python Pro, The Well-Grounded Python Developer: How the pros use Python and Flask, Object-Oriented Software Design in C++, Web Components in Action and 15 more.
What should I know before learning inheritance?
Manning books that teach inheritance usually introduce object, class, attribute and superclass first.
What is the difference between inheritance and composition?
Inheritance is a mechanism in which a derived type or descendant element receives properties or behavior from a parent, subject to rules that may allow specialization or overriding. Composition is the construction of a larger behavior, computation, or system by combining smaller functions, components, or operations.
What kinds of inheritance are there?
Kinds of inheritance include public inheritance and single inheritance.
What is inheritance a kind of?
Inheritance is a kind of class. A class is a programming-language construct that defines a type’s structure and behavior and provides a basis for creating or representing objects.
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.






















