Jump to content
  • Advertisement

Archived

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

jharkey

const question

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

hello, i was wondering what this means. void SomeFunction(int i) const; what is the const for, i understand this void SomeFunction(const int& i); i get that means that eventhough i is passed by reference, it doesnt allow you to modify it. but what is the first one?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Const on a member function in a class just means that the instance of the class will not be modified by the function.

Thus, if you have a const instance of that class, you could invoke the method in question. However, you can''t invoke a non-const method on a const class instance.

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.

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!