+ 1

Can anyone explain this code in detail ?

https://code.sololearn.com/cr2TZ90pcsfd/?ref=app

20th Jun 2018, 3:47 AM
Bhautik Donga
Bhautik Donga - avatar
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
20th Jun 2018, 4:26 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
You changed the return value of the func() method to 30 That's why it printed 30
20th Jun 2018, 4:28 AM
Dlite
Dlite - avatar