C++17 In Detail

22 June 2012

Const Correctness in C++


Memorize, memorize, memorize!!!


// value being pointed cannot be changed:
const char * ptr;


// address of the pointer cannot be changed, 
// but the value being pointed can be
char * const ptr;


// both value and the address of the pointer cannot be changed
const char * const ptr;

Those rules seem to be simple, but I sometimes forgot about them ;(

More info:



sign image taken from: http://openclipart.org/detail/3130/warning-notification-by-eastshores
C++17 In Detail
© 2017, Bartlomiej Filipek, Blogger platform
Disclaimer: Any opinions expressed herein are in no way representative of those of my employers. All data and information provided on this site is for informational purposes only. I try to write complete and accurate articles, but the web-site will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.