Const Correctness

suggest change

Syntax

Remarks

const correctness is a very useful troubleshooting tool, as it allows the programmer to quickly determine which functions might be inadvertently modifying code. It also prevents unintentional errors, such as the one shown in Const Correct Function Parameters, from compiling properly and going unnoticed.

It is much easier to design a class for const correctness, than it is to later add const correctness to a pre-existing class. If possible, design any class that can be const correct so that it is const correct, to save yourself and others the hassle of later modifying it.

Note that this can also be applied to volatile correctness if necessary, with the same rules as for const correctness, but this is used much less often.

Refrences :

ISO_CPP

http://stackoverflow.com/questions/136880/sell-me-on-const-correctness

C++ Tutorial

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents