There is a class A and it has the following operator() implementation:
void A::operator()(...parameters...) const
{
// operator body
}
What does this const mean?
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.
Methods in C++ can be marked as
constlike in the above example to indicate that the function does not modify the instance. To enforce this, thethispointer is of typeconst A* constwithin the method.Normally, the
thispointer within a method isA* constto indicate that we cannot change whatthispoints to. That is, so that we cannot dothis = new A().But when the type is
const A* constwe also cannot change any of the properties.