| High Integrity CPP Rule 8.4.11 | Use 'const' whenever possible. |
| Justification |
This allows specification of semantic constraint which a compiler can enforce. It communicates to other programmers that value should remain invariant - by explicit statement. For example, specify whether a pointer itself is const, the data it points to is const, both or neither: char* p1; // non-const pointer, non-const data const char* p2; // non-const pointer, const data char* const p3; // const pointer, non-const data const char* const p4; // const pointer, const data |
| Reference |
Effective C++ Item 21; |