Explain the class invariant.
- It's a condition that ensures correct working of a class and defines all the valid states for an object.
- When an object is created class invariants should hold.
- It is essential for them to be preserved under all operations of the class.
- All class invariants are both preconditions and post-conditions for all operations or member functions of the class.