dynamic_cast performs run-time type checking and pointer conversion within an inheritance hierarchy. When a Book pointer actually refers to Fiction, it produces a Fiction pointer; for a Cookbook, it returns nullptr. section 2.3.3
Filtering a catalogue by subclass
Catalogue::find iterates through Book pointers, casts each one to Fiction, checks for nullptr, then casts its Attributes pointer to FictionAttrs before matching attributes. The same approach handles Cookbook objects.
The cast solves a local type-selection problem but exposes broader design costs:
- It safely rejects incompatible objects instead of treating every Book as a Fiction. section 2.3.3
- It adds run-time checks, pointer conversions, subclass pairs, and overloaded operations for each new book kind. section 2.3.3

