I am reading some C++ text from the address https://cs.senecac.on.ca/~chris.szalwinski/archives/btp200.081/content/overl.html.
in the first lines, they say:
The signature of a member function consists of:
-
the function name,
-
the data types of its parameters,
-
the order of the parameters and
possibly -
the const status of the function.
I don’t understand what they mean by saying “the const status of the function“.
Can anyone elaborate on that, please?
Thanks.
In C++, you can declare a member function of a class to be
const, by appending that keyword to its signature (for instance,int MyClass:doSomething(int param) const {...}). Doing so guarantees that the function won’t change the (non-mutable) members of the class object on which the function is called – and hence it can be called withconstinstances of that class.It is permissible to have two different member functions for a class whose signature differs only in whether they are declared
constor not.