Error when I say int x =10

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;

}

Author: Padmapriya Muthu Subramanian
Login to Answer
Sort By:
Oldest
|
Newest
|
Vote
|
My Answer