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

Get my free ebook about C++17!

More than 50 pages about the new Language Standard.

C++17 in detail, by Bartlomiej Filipek

C++17 In Detail
© 2017, Bartlomiej Filipek, Blogger platform
Any opinions expressed herein are in no way representative of those of my employers.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.