Challenge 2: Fixing the Slicing Without Changing Circle's Construction — Possible Solution ==================================================================== #include class Shape { public: virtual double area() { return 0; } }; class Circle : public Shape { public: double radius; Circle(double r) : radius(r) {} double area() override { return 3.14159 * radius * radius; } }; int main() { Circle c(5.0); // unchanged from Challenge 1 Shape &s = c; // reference instead of a by-value copy -- no slicing std::cout << s.area() << std::endl; return 0; } Output: 78.5397 WHY THIS WORKS AS AN ANSWER ------------------------------ Circle c(5.0) is constructed identically to Challenge 1 -- the only change is that s is declared as Shape& (a reference) rather than a plain Shape (a value). Since a reference is just an alias for the existing Circle object (cpp1-2's own material) rather than a new, separately-copied Shape-sized object, s.area() correctly dispatches through Circle's own vtable, exactly matching the chapter's own advice to always use a pointer or reference for polymorphic objects rather than passing them by value.