H
Hans Van den Eynden
I thought that integers resized on the stack and that a value type was
just defined in the scope of the function. And when the function
returns the local variables were removed from the stack. But what is
the explication of this code??
int& dangling_reference();
int main(int argc, char *argv[])
{
int a;
a= dangling_reference();
cout<<a<<endl;
cin.get();
}
int& dangling_reference() {
int x=3;
return x;
}
just defined in the scope of the function. And when the function
returns the local variables were removed from the stack. But what is
the explication of this code??
int& dangling_reference();
int main(int argc, char *argv[])
{
int a;
a= dangling_reference();
cout<<a<<endl;
cin.get();
}
int& dangling_reference() {
int x=3;
return x;
}