Avoid Const Completely

One of two CeePlusPlus strategies for dealing with the ConstQualifier; the other is to practice ConstCorrectness.

When we avoid const completely, we never (OK, almost never) use the ConstQualifier in C++ programs as a modifier of a pointer or reference, save for the minimal set of cases where we have to use const to deal with language/library compatibility, or if necessary for an EmbeddedSystem (like data structures being in ROM).

Uses of const that act like Java's final keyword--declaring a local variable or class member to be of type "const int", are OK--most such variables are never (or rarely) aliased and thus don't suffer from the const propagation problem (See below).

Reasons to AvoidConstCompletely:


CategoryCpp

EditText of this page (last edited January 31, 2012) or FindPage with title or text search