can anyone explain the output?
c++, function
Solution
That's how static locals work - they persist the value between the function calls. Basically `fun()` has a static local and returns a reference to it, the effect is roughly the same as you would have with a global variable.
Problem
Can anyone explain the output? ``` #include<iostream> using namespace std; int &fun(){ static int x = 10; return x; } int main(){ fun() = 30; cout << fun(); return 0; } ``` output is 30