Skip to content

constptr vs ptrconst

Wu Jie edited this page Mar 30, 2014 · 1 revision

Constant pointer is NOT pointer to constant. Constant pointer means the pointer is constant. For eg:

Constant Pointer:

int * const ptr1 indicates that ptr1 is a pointer which is constant. This means that ptr1 cannot be made to point to another integer. However the integer pointed by ptr1 can be changed.

Where as a Pointer to constant is:

const int * ptr2 indicates that ptr2 is a pointer that points to a constant integer. The integer is constant and cannot be changed. However the pointer ptr2 can be made to point to some other integer.

Clone this wiki locally