B
Binary
Hi,
I am reading a chinese book about STL, the book says below code will
have no memory leak. I think its magic and wonder why the auto_ptr
knows the memory should be freed when leaving the function call:
void func()
{
auto_ptr<string> ps(new string("jjhou"));
cout << *ps << endl;
// leave the function without delte, the auto_ptr will release it
automatically
}
TIA.
ABAI
I am reading a chinese book about STL, the book says below code will
have no memory leak. I think its magic and wonder why the auto_ptr
knows the memory should be freed when leaving the function call:
void func()
{
auto_ptr<string> ps(new string("jjhou"));
cout << *ps << endl;
// leave the function without delte, the auto_ptr will release it
automatically
}
TIA.
ABAI