Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
An invariant is something that is assumed to be true.
For example, the sole integer member variable of a class called 'OddIntegerNumber' can reasonably be assumed to be an odd number.
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 13.7. Advice. page 387: '[11] Let a constructor establish an invariant, and throw if it cannot'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 13.7. Advice. page 387: '[18] Use "Resource Acquisition Is Initialization" and exception handlers to maintain invariants'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 13.7. Advice. page 387: '[20] Design your error-handling strategy around invariants'
- Bjarne Stroustrup. The C++ Programming Language (4th edition). 2013. ISBN: 978-0-321-56384-2. Chapter 16.4. Advice. page 479: '[3] Use public data (structs) only when it really is just data and no invariant is meaningful for the data members'
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.
