Isn't this a obvouis thing or am I missing something? You allocated on the stack, once it goes out of scope that object won't exist. So that pointer is invaild.
Normally i minimise the use of raw pointers in C++ using stl colletions, smart pointers and references.
My unserstanding is that the memory on the stack is again "free" as soon as the call returns. Any further calls will overwrite the memory contents while the call environment is setup etc. and therefore the pointer will point to junk.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.