passing by reference const

how do you pass by reference without altering its contents. So far I realized that putting const can alter its values but not the reference
Is it possible at all to pass by reference and not change its value.
func(const int& myint) ?
closed account (D80DSL3A)
Yes. If a function f() takes a value x this way:
f( const int& x )// using type int for example but this applies to any type
Then any code within f() that would change the value of x will cause an error.
Here x is passed by reference but its value cannot be changed.
Topic archived. No new replies allowed.