Skip to main content

Practice · 1 of 2

unique_ptr command stack

CHALLENGE
Difficulty: intermediate+25 XP

Complete CommandStack: void push(std::unique_ptr<Command> c) stores the command by transferring ownership (std::move), and void run_all() runs each command then pops it. A Command base with a virtual destructor is given. Implement a derived EchoCommand that records a message when run — the tests define a Recorder the EchoCommand must call.

Back to lesson: Practice: unique_ptr practice