+ 1
Can anyone explain this code in detail ?
2 Respuestas
+ 12
https://www.sololearn.com/Discuss/951659/?ref=app
fun() has a return type (int&), which means it returns the reference of the x .
fun() = 30; assigns 30 to the returned reference by fun(). and hence , the output is 30.
so static variable value only exist till the local scope of function after that it's value change when the fun() is assigned value 30
+ 1
You changed the return value of the func() method to 30
That's why it printed 30