Const (computer programming)

This is an old revision of this page, as edited by JTN (talk | contribs) at 17:28, 23 March 2005 (Category:C programming language family; {{compu-stub}}; embolden headword). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Const correctness is a programming language feature, its most famous implementor being C++. In languages supporting this feature, variables can be said to be 'const'. When a const object is referenced, only the methods declared as const may be called. This allows programmers to formalise a specific design contract: they can promise at compile-time that a parameter of a function cannot be modified destructively.

Of course, const methods can only call other const methods, and cannot assign member variables