please look at this code firstly . I run it on g++ complier. I want to know how it will act when the function "add" return a reference to local variable , but it run correctly, no crash . Why ?
int & add (int a,int b) {
int c = a + b ;
return c ;
}
int main()
{
cout<<add(1,2)<<endl;
int a = add(1,2);
cout<<a<<endl;
}