0
Why is value of variable behaving this way? Pass-by-reference [Solved]
Hi. I AM A LITTLE CONFUSED AS TO WHY THE VALUE OF A IS 6 AND NOT 10. WHY IS THIS HAPPENING EXACTLY? THANKS FOR THE HELP :) AND SORRY FOR THE CAPITALIZATION , I CANNOT TURN IT OFF ON MY IPAD WHEN WRITING IN THIS FIELD, STRANGE AS IT MAY SEEM... https://code.sololearn.com/ca177a168A19/?ref=app
3 odpowiedzi
+ 3
The variable b has overwritten the a, because it was declared in the function last.
+ 2
you are passing the same variable reference to both arguments, so when you assign first a to 10 and second b to 6, you refer to same emplacement, so later value remain ^^
by same way, if you output value of c, you'll get 12 and not 16 ;)
+ 1
Thank you very much :) ++