Skip to main content
Module 6 · Lesson 1 of 213/26 in the course~14 min
Module lessons (1/2)

Inheritance in C++

Lesson preview5 hands-on exercises readyCourse C++ · Module 6 — Inheritance and Polymorphism

Create class hierarchies with public inheritance, understand the protected specifier, and invoke base class constructors.

What you'll learn in this lesson

  • Create class hierarchies with : public Base inheritance by expressing is-a relationships.
  • Distinguish visibility of private vs protected in derived classes.
  • Delegate arguments to the base class constructor via : Base(args) and know the constructor/destructor order.

Overview

Inheritance allows a derived class (Car) to inherit members and public contract from a base class (Vehicle). In C++ the standard form of public inheritance is written : public Base.

Without : public, a class Derived : Base would use private inheritance by default hiding the base methods from the outside world! Therefore always specify : public:

Sections covered in this lesson

  1. 11. Inheritance : public and Accessibility protected
  2. 22. Base Class Initialization and Construction/Destruction Order
  3. 33. Inheritance vs Composition (has-a)
  4. 44. Delegation to the Base Builder + using
  5. 5Practical exercises
  6. 6Check for understanding
Pro Lesson · Module 6 — Inheritance and Polymorphism

Unlock "Inheritance in C++" and the full Course C++ curriculum

Create class hierarchies with public inheritance, understand the protected specifier, and invoke base class constructors.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course C++ plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.