The const keyword, shown after the function, guarantees the caller of the function that no member data variables will be changed.
For example, given this class,
// in .cpp
void Node::changeValue() const { this->value = 3;
There is an exception to this rule. If you declare that the member data variable has been changed, then it can be changed regardless of whether the const function is declared. Using mutable is a rare situation when an object is declared persistent, but in practice there are member data variables that need options to change. One possible use case is to cache a value that you might not want to repeat the original calculation. This is usually a rarity ... But it's good to know about it.
For example, given this class,
// in .cpp
void Node::changeValue() const { this->value = 3;
source share