Who`s Afraid to Be Const Correct? Help Your Compiler Help You - Conclusion
(Page 4 of 4 )
I have shown you how to read and use const in a sensible way and which pitfalls you can expect when you want to be const correct. Don’t be discouraged when you discover that making your current code base const correct takes a lot of effort… there is a very valid reason for it!
Be suspicious when you see const_cast being used and keep in mind what the difference between bitwise constness and conceptual constness is.
If you aim to write high quality solid code, it will have to be const correct at least!
References[K&R] – Kernighan and Ritchie
“The C Programming Language” – ISBN 0131103628
[Meyers] – Scott Meyers
“Effective C++” – ISBN 0201924889
item 20 ‘Avoid data members in the public interface’
item 21 ‘Use const whenever possible’
[Sutter] – Herb Sutter
“Exceptional C++” - ISBN 0201615622
[Lakos] – John Lakos
“Large Scale C++ Software Design” – ISBN 0201633620
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |