Suppose I have some variables that are changed only in a couple of functions, but which need to be accessed in a bunch of other functions.
One way is to pass these variables to all functions, as const to functions which should not change them.
This is a bit inelegant because it introduces clutter whenever I call functions.
Is there another way where I can state in a function body something like "for the scope of this function, treat these variables as const"?
if you pass a variable to a function, it simply gets a copy of it. it won't change the actual variable.
if you want to change the variable, you have to use pointers
If you do not need to have a guarantee that those functions will not be ever able to change value of global, and simply want to protect yourself from accidental error, you can make a const reference to this global: