Consider the simple program below, which attempts to iterate through the values of a set using NON-const references to the elements in it:
#include
std::set uses the contained values to form a fast data structure (usually, a red-black tree). Changing a value means the whole structure needs to be altered. So, forcing constness, std::set prevents you from pushing it into a non-usable state.
std::set
const