9.10. const Objects and const Member Functions
Let’s see how the principle of least privilege applies to objects. Some objects need to be modifiable and some do not. You may use keyword
const to specify that an object is not modifiable and that any attempt to modify the object should result in a compilation error. The statement
const Time noon( 12, 0, 0 );
noon of class
Time and initializes it to 12 noon. It’s possible to instantiate
const and non-
const objects of the same class.
Software Engineering Observation 9.8
Attempts to modify a const object are caught at compile time rather than causing execution-time errors. ...