+ 1
different output depending on scopes
code below shows how if use assign a ref and then change the value w ptr in different scope, ref continues w the old value. Instead if do it at same scope, no. why? its cause the aux reference? thx https://code.sololearn.com/c77bC48EU746/?ref=app
3 odpowiedzi
+ 4
"ref = n" == ref=100;
If you try cout<<aux it gives 100 too, ref refers aux always.. e.g.: the first assignment of ref is the initialization of ref => address of aux, the 2nd assignment is a normal value assignment.
There is a something wrong about ptr in "TEST=true" scope here instead, the variable it points no longer exists after "if(true)" block..
Here there's why..
https://stackoverflow.com/questions/6441218/can-a-local-variables-memory-be-accessed-outside-its-scope
+ 3
Thank you!
Good job btw.. your approach will make you a strong programmer 👍
+ 1
haha AZTECCO good answers as ever