08
Dec
What’s the difference between “const X* p”, “X* const p” and “const X* const p”?
Related Blog Items
- How is "const correctness" related to ordinary type safety?
- const correctness
- What is allowed in C, but not in C++?
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- Reference Counting
You have to read pointer declarations right-to-left.
- const X* p means “p points to a X that is const” ? that is, the Fred object can’t be changed via p.
- X* const p means “p is a const pointer to a X” ? that is, you can change the X object via p, but you can’t change the pointer p itself.
- const X* const p means “p is a const pointer to a const X” ? that is, you can’t change the pointer p itself, nor can you change the X object via p.
source: USENET
Popularity: 4%
You need to log on to convert this article into PDF
Related Blog Items - How is "const correctness" related to ordinary type safety?
- const correctness
- What is allowed in C, but not in C++?
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- Reference Counting
Related Blog Items
- How is "const correctness" related to ordinary type safety?
- const correctness
- What is allowed in C, but not in C++?
- Safe String Copy(strcpy) and Concatenate(strcat) Operations
- Reference Counting
No Comments
No comments yet.