Search

Sponsored Links

Meta

Categories

Archives

Recent Posts

RSS Feeds

08
Dec

What’s the difference between “const X* p”, “X* const p” and “const X* const p”?

Related Blog Items

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

No Comments

No comments yet.

Leave a comment

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-spam image