INHERITANCE in C++ | most of the things you need to know for OOP and beyond 🚀

Help me keep doing these videos! This works relies on your support! You can show it in one of these ways: 📚 Start a FREE Audible trial: https://www.audibletrial.com/CodeForY... 🛍️ Buy gear I use to make this video: https://github.com/cpp-for-yourself/s... 💶 Directly become a sponsor on GitHub: https://github.com/sponsors/niosus 📺 Watch my videos to the end and leave comments ⁉️ Find your way to support this work here: https://github.com/cpp-for-yourself/s... In this video we cover most of the things that one might encounter when working with inheritance in modern C++. We go over a broad list of topics, starting from why we care about inheritance (spoiler alert: to enable dynamic polymorphism) and digging down into the rabbit hole of how it mixes with implementation inheritance (not that well), what is object slicing and what we need to keep in mind should we want to use inheritance and embrace reference semantics. 📚 Link to the script to this video on GitHub: https://github.com/cpp-for-yourself/s... 🔗 Links ⏺ Avoid protected data: https://isocpp.github.io/CppCoreGuide... ⏺ CRTP: https://en.wikipedia.org/wiki/Curious... ⏺ Trait is_integral: https://en.cppreference.com/w/cpp/typ... ⏺ Trait integral_constant: https://en.cppreference.com/w/cpp/typ... ⏺ Virtual method table: https://en.wikipedia.org/wiki/Virtual... ⏺ Virtual destructor: https://en.cppreference.com/w/cpp/lan... ⏺ Object slicing: https://www.learncpp.com/cpp-tutorial... ⏺ Polymorphic objects: https://en.cppreference.com/w/cpp/lan... ⏺ Liskov substitution principle: https://en.wikipedia.org/wiki/Liskov_... ⏺ Distinguish between implementation and interface inheritance: https://isocpp.github.io/CppCoreGuide... ⏺ Google style on inheritance: https://google.github.io/styleguide/c... ⏺ Implementation inheritance is evil: http://whats-in-a-game.com/implementa... ⏺ Use multiple inheritance for interfaces: https://isocpp.github.io/CppCoreGuide... Contents 00:00 Intro 00:40 Dependency inversion principle motivation 03:06 Dependency inversion principle 05:29 Can we use templates for dependency inversion? 05:55 Implementation inheritance basics 07:30 Access control with inheritance 10:23 Upcasting 11:27 When to use implementation inheritance 13:20 Dynamic polymorphism with virtual 14:20 Virtual method table (vtable) 15:39 Downsides of using virtual 16:30 Virtual destructor and why we need it 17:54 Rule of all or nothing and reference symantics 18:34 Object slicing 19:20 Downcasting with dynamic_cast 21:05 Pure virtual functions, abstract classes, and interfaces 22:03 Keyword final 22:59 Multiple inheritance and when to use it 23:34 Final good style example and summary Credits ⏺ Video by Tima Miroshnichenko: https://www.pexels.com/video/two-youn... ⏺ Video by Mati Mango: https://www.pexels.com/video/a-man-ha... ⏺ Video by freepik: https://www.freepik.com/free-video/st... ⏺ Ticking sound: https://freesound.org/people/bySeb/so... #cpp #cplusplus #programming #coding #softwaredesign #education