test1 is correct(compiling with g++), but test2 is error. Why?
int& test1(){
int a = 10;
int& res = a;
return res;
}
int& test2(){
int a = 10;
return a;
}
test1 is correct(compiling with g++), but test2 is error. Why?
int& test1(){
int a = 10;
int& res = a;
return res;
}
int& test2(){
int a = 10;
return a;
}