const
after a function declaration means that the function is not allowed to change any class members (except ones that are marked mutable
). const
in a function defintion means the same as const
for a variable: that the value is not allowed to change.
const
is a highly overloaded operator and the syntax is often not straightforward in combination with pointers. Some readings about const correctness and the const keyword: