Skip to main content

Practice ยท 2 of 3

Chaining through *this

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.

Difficulty: intermediate

Back to lesson: Practice: static members and this