Programming by Contract: The major mechanism for expressing functional properties is the use of assertions—statements involving conditions expressed as Boolean expressions which cause program termination if the condition is not met.
Assertions are usually conditionally compiled, and therefore they should be programmed side-effect-free with respect to object states. For C/C++, this is implemented by means of the pre-processor, not integrated into the language. It works well for “flat” procedural programs, but has limitations with object-oriented programming (OOP).
The preferred way to integrate assertions into an object-oriented system is through Programming by Contract (PbC) (Meyer 1992). PbC extends and provides specialized assertions by defining standard scopes and evaluation rules for them, especially in the context of object-oriented programming.