What is the difference between making it local and static? Why is there an error and fun() outputs nothing when I make it just int without using static ?
#include<iostream>
using namespace std;
int &fun()
{
int x = 10;
return x;
}
int main()
{
fun() = 30;
cout << fun();
return 0;
}