int * func()
{
int a=10;
int* p=&a;
return p;
}
int main()
{
int* q=func();
}
does q point to a=10 before a is destroyed?
Or better said, what is the order of execution?
This is how I taught:
1. func returns p;
2. q gets the adress of p; (q points now to a=10)
3. a is destroyed (q points now to a garbage value)
or 1,3,2 ?
Which is the correct order?
This post has been edited by livium: 09 April 2011 - 07:57 AM

New Topic/Question
Reply



MultiQuote





|