Oreilly - Inheritance and Polymorphism with C++
by Jason Turner | Released July 2016 | ISBN: 9781491961926
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::functionJason 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 EmptyCrate.com blog. Show and hide more Publisher resources Download Example Code
- Introduction
- What We Will Cover In This Video 00:02:26
- About The Author 00:02:06
- Compile Time Vs. Runtime Polymorphism 00:01:54
- Basics Of Inheritance 00:03:50
- Basics Of Templates 00:05:27
- Inheritance
- Access Specifiers 00:05:03
- Friends 00:03:13
- Nested And Local Class Access 00:03:18
- Virtual Functions And Abstract Base Classes 00:03:39
- Virtual Destructors 00:04:39
- Using Override And Final 00:05:20
- Exercise 1 - Chapter 2 - Object Factory 00:03:28
- Inheritance Gotchas
- Friendship Is Not Inherited Or Transitive 00:03:55
- Be Aware Of Slicing 00:04:30
- Understanding Overloading Vs Overriding 00:03:51
- Using The Using Declarations 00:03:55
- Exercise 1 - Chapter 3 - Clean Up Inheritance 00:03:05
- Exercise 2 - Chapter 3 - Fix The Error 00:02:01
- Inheritance - Advanced Topics
- Covariant Return Types 00:04:01
- Multiple Inheritance 00:05:04
- Virtual Inheritance 00:04:23
- Private Constructors 00:04:01
- Private Destructors 00:04:48
- Dynamic_Cast And Static_Cast 00:05:44
- Mixins And CRTP 00:03:02
- Implementating Pure Virtual Functions 00:02:13
- Exercise 1 - Chapter 4 - Creating A Mixin 00:05:18
- Exercise 2 - Chapter 4 - Fixing Up The Inheritance 00:05:10
- Polymorphism Cost And Optimization
- Cost Of Adding Virtual Functions 00:03:17
- Cost Of Virtual Function Calls 00:04:26
- Cost Of Virtual Destruction 00:05:32
- Avoid Template Bloat With Smart Pointers 00:04:59
- Empty Base Optimization 00:04:03
- Exercise 1 - Chapter 5 - Reduce Program Execution Cost 00:05:01
- Exercise 2 - Chapter 5 - Reduce Program Compiled Size 00:05:05
- Conclusion
- Best Practices Summary 00:03:10
- Type Erasure 00:03:38
- Function As Polymorphism 00:04:11
- Any And Union As Polymorphism 00:03:06
- Exercise 1 - Chapter 6 - Function Object 00:02:44
- Exercise 1 - Chapter 6 - Function Object Solution 00:05:17
- Exercise 2 - Chapter 6 - Any Implementation 00:02:38
- Exercise 2 - Chapter 6 - Any Implementation Solution 00:07:51
- Wrap Up And Thank You 00:01:34
Show and hide more