C++ Address-of Operator &
[1] char f1(char c) { return c == 'z' ? 'a' : c + 1; } char f2(char &c) { c = f1(c); return c; } int main() { char x = 'x'; cout << f2(x); cout << f2(x); cout << f2(x); } Output: yza f1 function changes the value of its argument as well as f2 function. Do we pass the x variable itself to f2 above or do we pass its address? I thought we should pass the address if we want our variable to change its value. What is the difference between these two functions' declarations? [2] Imagine we have a similar function with such a declaration: char f3(char *c); that changes its arguments' value as well. What would be the result of these actions: a) char x = 'x'; cout << f3(x); b) char x = 'x'; cout << f3(&x); ? How should I interpret receiving variables/pointers/addresses as arguments by functions? Thanks in advance.