Skip to main content

Checkpoint: Memory & Lifetime

Challenge on lesson: Checkpoint: Memory & Lifetime

Implement long bounded_total(const long* values, int count, long cap): sum up to count values read through the pointer (stop early once the running total would exceed cap — in that case return cap). A null pointer with count > 0, or a negative count, must throw std::invalid_argument.

Difficulty: intermediate

Back to lesson: Checkpoint: Memory & Lifetime