Question 3
Back to Exercise
What is a class invariant?
- A A const data member
- B A condition that holds for every object of the class between member function calls, e.g. "balance ≥ 0" Correct
- C A variable that never changes type
- D A static member
Correct Answer: Option B
The constructor establishes it and every public member function preserves it. Private data makes this enforceable.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!