0

Reference with fonction

When i do: void incre(int &var); int main() { int var = 20; incre(var); cout<<var<<endl; return 0; } void incre(int &var) { var++; } Why does it work ? My fonction need a reference and i havent

6th Sep 2019, 5:18 PM
Joel Karn
5 Antworten
+ 3
you have a reference variable which is another name to the same address on RAM
6th Sep 2019, 5:49 PM
ABADA S
ABADA S - avatar
+ 1
no
6th Sep 2019, 6:03 PM
Cat Sauce
Cat Sauce - avatar
0
?? it does work. edit.. sorry mis-read....thought you ment 'why it doesn't work'.
6th Sep 2019, 5:25 PM
rodwynnejones
rodwynnejones - avatar
0
It works. Why ?
6th Sep 2019, 5:34 PM
Joel Karn
0
I dont need To do ? : Int var = 20; Int &rVar = var ; Incre(rVar);
6th Sep 2019, 5:57 PM
Joel Karn