I am supposed to determine whether this function is syntactically correct:
int f3(int i, int j) { const int& k=i; ++i; return k; }
I have tested it out and it compiles with my main function.
I do not understand why this is so.
Surely by calling the function f3 I create copies of the variables iand j in a new memory space and setting const int& k=i I am setting the memory space of the newly created k to the exact the same space of the memory space of the copied i, therefore any change, i.e. the increment ++iwill result in ++k which is not possible given that it was set const
Any help is greatly appreciated