Class invariants are the conditions which have to be true for the valid state of the class. If class invariants are violated, the class would be in invalid state and undefined behaviors could occur.

For example,

struct Fraction 
{
    int numerator {0};
    int denominator {1}; // class invariant: should never be 0
}

References

  1. https://www.learncpp.com/cpp-tutorial/introduction-to-classes/