Core · Module 6 · Lesson 6 of 6
Project: A Polymorphic Library Catalogue
Combine inheritance, virtual dispatch, and safe teardown into a catalog that stores mixed items behind base handles and reports per-kind loan periods.
By the end you can
- Build a mixed catalog using base handles and unique ownership
- Use virtual dispatch for per-kind loan and print behavior
- Ensure complete teardown through a virtual base destructor
Builds on The Diamond and Virtual Inheritance.
01 · A question first
Closing time arrives with books, DVDs, and magazines still on the carts. One loop must print each title with its loan period, then release every item without leaks. How does a single container hold three kinds, print three answers, and destroy each correctly?
Make a guess before you read on.
02 · The idea
Members only
Unlock the full lesson
This lesson is part of the membership. Join to read it in full, along with every other premium deep dive.
What's inside
- Start with the full catalog
- How the pieces combine
- Why the design stays correct
- Cost and growth path
- Pitfalls that capstones reveal
- Analogy and a slicing check
- Complete solution
- Where this is used
03 · Practice
Something wrong with this lesson? Report a problem