Quantcast
Channel: Bartek's coding blog
Viewing all articles
Browse latest Browse all 325

Const Correctness in C++

$
0
0

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

Viewing all articles
Browse latest Browse all 325

Trending Articles