j is destroyed when the function calls return
k is destroyed at the end of the enclosing brackets
If i pass in 9 for j, k is created and will be assigned 81
Returning k will set func1 which is a reference to an integer = k
Returning will immediately terminate the function
My question is, are k and j terminated at the return statement?
If they are func1 should reference nothing...
But i have tried to run this code and it works...
int& func1(int j){
int k = j*j;
return(k);
}