Skip to main content

Checkpoint: Inventory of owned items

Challenge on lesson: Checkpoint: Ownership Transfer

Complete Inventory managing std::vector<std::unique_ptr<Item>>: void add(std::unique_ptr<Item>) stores it; std::unique_ptr<Item> take(const std::string& name) finds the item, moves it out of the vector (ownership leaves the inventory), erases the now-empty slot, and returns it — or returns nullptr when absent. Item (name-based) is partially given.

Difficulty: intermediate

Back to lesson: Checkpoint: Ownership Transfer