0
why this output 5 and why not 2? #include <iostream> using namespace std; void func(int &x) { x=5; } int main() { int x=2; func(x); cout<<x; }
7 Respostas
+ 3
because you call the function func() and his reference as argument is the variable x inside the function that have value 5...when we call the function...the function pick the reference variale x inside of that function...not the variable on main() function...hope that this helps ;-)
+ 1
Not at all...hey have you whatsapp...if you have lets have some programming chat at there...would be interesting and I will be honored
0
thank Carlos
0
yea, what's your WhatsApp no.
0
its from Brazil. .. here: +5597981080851
0
and your no.?
0
+918107350482