Archived

This topic is now archived and is closed to further replies.

const

This topic is 5653 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Forgive me if I am wrong. This answer is based on my memoery alone.

>> const char*

A non-constant pointer to a constant char

>> char* const

Not legal.

>> char const*?

A constant pointer to a non-constant char.

So you can also write:

const char const*

The point is that you write const in from of the element you want constant.

Share this post


Link to post
Share on other sites
quote:
Original post by _johan
What''s the difference between:

const char*

That is a non-const pointer to const char.
quote:

char* const

That is a const pointer to non-const char.
quote:

char const*?

That is also a non-const pointer to const char (i.e. the same as the first).

Share this post


Link to post
Share on other sites
quote:
Original post by fallenang3l
SabreMan is correct .
Felonius, better work on those memory skills .




Hehe, curiously those three examples presented by the original poster is those that can be found in Stroustrups book on page 96. And yes, Sabreman got it right - but I only missed number 2.

[edited by - felonius on June 24, 2002 3:47:31 PM]

Share this post


Link to post
Share on other sites