J
John
Hi all:
Just learn to use smart pointer. I get a question. In the following
code:
void foo()
{
auto_ptr<MyClass> p(new MyClass);
p->DoSomething();
}
By the end of function foo(), the memory that is allocated to p will
be automatically deallocated. But if I have other functions that need
to access the memory allocated to p, and eventually that memory will
be deallocated by one function. So I do not want the memory allocated
to p to be deallocated by the end of function foo(). What should I do?
Thanks a lot.
John
Just learn to use smart pointer. I get a question. In the following
code:
void foo()
{
auto_ptr<MyClass> p(new MyClass);
p->DoSomething();
}
By the end of function foo(), the memory that is allocated to p will
be automatically deallocated. But if I have other functions that need
to access the memory allocated to p, and eventually that memory will
be deallocated by one function. So I do not want the memory allocated
to p to be deallocated by the end of function foo(). What should I do?
Thanks a lot.
John