What exactly does the const keyword in C++ mean when it’s written at the end of a member function (after the argument list)?
What exactly does the const keyword in C++ mean when it’s written at the
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It means that
*thisisconstinside that member function, i.e. it doesn’t alter the object.This means that a
constmember function can be called on aconstinstance of the class. A non-constmember function can’t be called on [1]aconstobject, since it could potentially try to modify it.[1] Note: a temporary is not a
constobject unless it’s ofconsttype.