I think I haven't grasped the proper idea behind returning something that is const.
If I'm having a function which returns const value, doesn't it means that I cannot change the value after I returned it?
Why the compiler allows me to cast my const to a non-const variable?
Or it works only with const pointers?
const int foo(int index) {
return ++index;
}
int main(){
int i = foo(1); // why can I do this?
++i;
return 0;
}