I thought keyword const was what kept a function from changing values (aka data).
Or am I reading your post wrong?Code:
int x = 4;
void change(int & z)
z = 5; //x now equals 5 as well eventhough reference used rather than pointer
void change(const int & z)
z = 5; //error, z is a const reference and value/data cannot change
void change(int & z) const
z = 5; //change() is a const function and promises not to change parameters passed in.
void change(const int & z) const
z = 5; //okay I'm paranoid and prone to overkill, either of the const should prevent data passed in from changing, both const aren't needed. This is an error twice over.