← Encapsulation, const Correctness & static Members

Fix: const Violation

hard

This doesn’t compile. Submit it as-is and read the error before changing anything – it’s the exact const violation from the lesson, just triggered by a member function instead of a plain pointer.

deposit is marked const, which promises it won’t modify the object – and then its whole job is modifying balance. Those two things can’t both be true. The fix isn’t in the arithmetic; it’s removing const from deposit’s own declaration, the same “recognize when const is simply wrong for this function” lesson as Module 2’s pointer-focused version of this exact exercise.

Your solution

"Run" uses the sample stdin ("100 50"). "Submit" checks your code against all 3 test cases.

Test results

Submit your solution to run it against all test cases.

Hints

    Reference solution