Skip to content

const and pointers

MarekBykowski edited this page May 26, 2026 · 1 revision
const int *p1 = &x;        // pointer to const int
int *const p2 = &x;        // const pointer to int
const int *const p3 = &x;  // const pointer to const int
Pointer *p (value) p (address)
const int *p1 ✗ locked ✓ allowed
int *const p2 ✓ allowed ✗ locked
const int *const p3 ✗ locked ✗ locked

💡 Read right→left: const int *p = "p is a pointer to const int"

Clone this wiki locally