& before function arg in cpp 1

& before function arg in cpp

// pass 'x' by reference
void f1(int &x){
	...
}

// pass 'x' by value
void f2(int x){
	...
}

Here is what the above code is Doing:
1. The function f1 is taking an int as an argument and passing it by reference.
2. The function f2 is taking an int as an argument and passing it by value.

Similar Posts