Inheritance and Polymorphism with C++

Video description

Gain new control of your code through a clear understanding of inheritance and polymorphism in C++. Expert Jason Turner teaches you the basics, the gotchas, the implementation and optimization of polymorphism and inheritance through live coded demonstrations and hands-on exercises. To get the most out of the course, learners should already have a basic understanding of C++ programming.

  • Discover the differences between runtime and compile time polymorphism and how to combine them to create powerful constructs
  • Understand class hierarchies in C++
  • Learn to control aspects of a class using access specifiers
  • Explore covariant return types, multiple and virtual inheritance, private constructors, destructors, mixins, CRTP, and other advanced topics
  • Review the cost and optimization methods of polymorphism, as well as the trade-offs considered when designing libraries
  • Gain the ability to implement the std::any and std::function
Jason Turner has over 15 years of programming experience specializing in cross-platform development, scripting of C++ libraries, and automated testing and code quality analysis. Jason is the co-creator and maintainer of the embedded scripting language for C++, ChaiScript, and is the author and curator of the forkable coding standards document, C++ Best Practices. He has spoken at CppCon in Bellevue, Washington, C++Now in Aspen, Colorado, and, is the co-host of CppCast, the podcast for C++ developers. You can discover articles by Jason on his blog.

Publisher resources

Download Example Code

Table of contents

  1. Introduction
    1. What We Will Cover In This Video
    2. About The Author
    3. Compile Time Vs. Runtime Polymorphism
    4. Basics Of Inheritance
    5. Basics Of Templates
  2. Inheritance
    1. Access Specifiers
    2. Friends
    3. Nested And Local Class Access
    4. Virtual Functions And Abstract Base Classes
    5. Virtual Destructors
    6. Using Override And Final
    7. Exercise 1 - Chapter 2 - Object Factory
  3. Inheritance Gotchas
    1. Friendship Is Not Inherited Or Transitive
    2. Be Aware Of Slicing
    3. Understanding Overloading Vs Overriding
    4. Using The Using Declarations
    5. Exercise 1 - Chapter 3 - Clean Up Inheritance
    6. Exercise 2 - Chapter 3 - Fix The Error
  4. Inheritance - Advanced Topics
    1. Covariant Return Types
    2. Multiple Inheritance
    3. Virtual Inheritance
    4. Private Constructors
    5. Private Destructors
    6. Dynamic_Cast And Static_Cast
    7. Mixins And CRTP
    8. Implementating Pure Virtual Functions
    9. Exercise 1 - Chapter 4 - Creating A Mixin
    10. Exercise 2 - Chapter 4 - Fixing Up The Inheritance
  5. Polymorphism Cost And Optimization
    1. Cost Of Adding Virtual Functions
    2. Cost Of Virtual Function Calls
    3. Cost Of Virtual Destruction
    4. Avoid Template Bloat With Smart Pointers
    5. Empty Base Optimization
    6. Exercise 1 - Chapter 5 - Reduce Program Execution Cost
    7. Exercise 2 - Chapter 5 - Reduce Program Compiled Size
  6. Conclusion
    1. Best Practices Summary
    2. Type Erasure
    3. Function As Polymorphism
    4. Any And Union As Polymorphism
    5. Exercise 1 - Chapter 6 - Function Object
    6. Exercise 1 - Chapter 6 - Function Object Solution
    7. Exercise 2 - Chapter 6 - Any Implementation
    8. Exercise 2 - Chapter 6 - Any Implementation Solution
    9. Wrap Up And Thank You

Product information

  • Title: Inheritance and Polymorphism with C++
  • Author(s): Jason Turner
  • Release date: July 2016
  • Publisher(s): Infinite Skills
  • ISBN: 9781491961926