Jump to content
  • Advertisement
Sign in to follow this  
beebs1

Const

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

Hiya, I thought I understood const and const parameters, but I've just come across a couple of lines that I really don't understand.
virtual bool HandleEvent( Event const &ev ) = 0;
EventType const	&GetType() const;

// and finally...
explicit Event( wchar_t const * const pchEventTypeName )
The first line - if the const was before Event, it would mean that ev will not me modified by the function. What does it mean in this position? The second line - the last const means that GetType will not modify any member variables, and I'd guess that the first const means that the return value cannot be modified by the calling code... right? The third line (a ctor) - I'm not even going to try and guess what those consts mean... :( Many thanks for any explanations. [smile] I always try and write const-correct code for readability, but I've never seen those before. Apparantly compilers can perform optimisations on const parameters and the like as well.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!