Jump to content
  • Advertisement

Archived

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

_johan

const

This topic is 6019 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

What''s the difference between: const char* char* const char const*? I''m not sure if they''re all correct...

Share this post


Link to post
Share on other sites
Advertisement
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!