In particular, Betrand Meyer has thought a lot about how assertions should be integrated into an object oriented language. He calls this Design by Contract . Since people are fallible the function should include preconditions to assert that the client is correctly calling the function and postconditions to assert that the function behaved correctly. The second key component of DBC are class invariants. For example, one invariant for a vector class might be that the total buffer size is always greater than or equal to the bytes in use.
Invariants are useful for ensuring that objects behave as they're supposed.
This is especially useful for the more complex objects. For example, in another lifetime, I implemented a red-black tree. This is a quite complex version of a balanced tree. Using an invariant made it much easier for me to verify that my code never veered from the constraints that make a tree red-black. Invariants allow base classes to catch improperly written subclasses.