Skip to main content

Practice ยท 1 of 2

unique_ptr command stack

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.

Difficulty: intermediate

Back to lesson: Practice: unique_ptr practice