Archived

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

jharkey

const question

Recommended Posts

jharkey    110
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
Guest Anonymous Poster   
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