Challenge 2: A Rule-of-Zero Class With a unique_ptr Member — Possible Solution ==================================================================== #include #include class Owner { public: std::unique_ptr value; Owner(int v) : value(std::make_unique(v)) {} // no destructor, no copy/move constructor, no copy/move assignment // written by hand anywhere -- the compiler generates all of them }; int main() { Owner a(42); Owner b = std::move(a); // moves the unique_ptr member correctly if (a.value == nullptr) { std::cout << "a's value is now null after the move" << std::endl; } std::cout << "b's value: " << *b.value << std::endl; return 0; } Output: a's value is now null after the move b's value: 42 WHY THIS WORKS AS AN ANSWER ------------------------------ Owner never defines a destructor, copy constructor, or move constructor by hand -- per the Rule of Zero, its ONLY member is a unique_ptr, an RAII type that already correctly implements move semantics itself. The COMPILER-GENERATED move constructor for Owner simply moves each member in turn, which for a unique_ptr member means correctly transferring ownership (nulling out a's own copy) -- exactly matching unique_ptr's own move behavior from cpp2-4, with zero hand-written resource-management code in Owner itself.