E
emannion
I am trying to clear up some reference questions
if I have a function that returns a reference to an int will that data
be lost when the function goes out of scope
int& retRef()
{
int j=10;
return j;
}
int main()
{
int& k = retRef();
int l = k;
return 0;
}
k is set to 10 after retRef() is called from main, I thought this
would not be possible if retRef() goes out of scope.
Can anyone answer this.
em
if I have a function that returns a reference to an int will that data
be lost when the function goes out of scope
int& retRef()
{
int j=10;
return j;
}
int main()
{
int& k = retRef();
int l = k;
return 0;
}
k is set to 10 after retRef() is called from main, I thought this
would not be possible if retRef() goes out of scope.
Can anyone answer this.
em