Skip to main content

Practice · 2 of 3

Chaining through *this

CHALLENGE
Difficulty: intermediate+25 XP

Implement class Ledger with private long total_{0};, Ledger& add(long cents) and Ledger& undo(long cents) (each updates total_ and returns *this), plus long total() const. The test chains calls.

Back to lesson: Practice: static members and this