+ 2
May you explain the code please? why it is giving 20 as output?
#include<bits/stdc++.h> using namespace std; void func(int&x) { x=20; } int main() { int x=30; func(x); cout<<x; }
2 ответов
+ 4
thank you.
+ 3
Because you pass by reference.
Meaning that you manipulate the variable x at the same memory address and don't create another local x in the function.