Challenge 2: Fixing the Diamond With virtual Inheritance — Possible Solution ==================================================================== #include #include class Animal { public: std::string name; }; class Swimmer : virtual public Animal {}; class Flyer : virtual public Animal {}; class Duck : public Swimmer, public Flyer {}; int main() { Duck d; d.name = "Donald"; std::cout << d.name << std::endl; return 0; } Output: Donald WHY THIS WORKS AS AN ANSWER ------------------------------ Adding virtual to BOTH Swimmer's and Flyer's own inheritance from Animal (per the chapter's own warn-box, both paths must agree) means Duck now contains exactly ONE shared Animal sub-object instead of two -- d.name unambiguously refers to that single shared name field, so the assignment and the subsequent read both compile and produce the expected result, resolving the exact ambiguity Challenge 1 demonstrated.