+ 1
Why B =2 in answer?
void f(int &x){ cout<<x++; x=2; } int main(){ int a=3; int &b=a; f(a); cout<<" b"<<b; }
3 Antworten
+ 10
When you do
int &b = a;
b is simply an alias for a. (i.e. b is a).
a gets passed into f() via reference, and the value is altered to 2.
+ 2
because it is passed by reference so its value can be modified by the function f
- 1
watch my sudoku solver in python))