Practice mode C++

Which declaration makes p a constant pointer to a modifiable int?

Correct answer C. int* const p = &x;

Explanation

Read pointer declarations from right to left. int* const p says p is a const pointer to int: p cannot be repointed, but *p can be changed. const int* p and int const* p are the same thing, a pointer to const int, where p can move but *p cannot be modified. const int* const p makes both the pointer and the pointee read-only.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.