Memory deallocation with smart pointer
<p>in C++, suppose there is a method in a Helper class which returns me a pointer to another object. I don't have any more information about this method except the method signature and the type of returned object. How to do memory management in this case?</p>

<p>I attempted to use smart pointer as this function below:</p>

<pre><code>void f() {
   auto_ptr&lt;SomeClass&gt; p_someClass = p_Helper-&gt;getSomeclass();
   p_someClass-&gt;doSomething();
}
</code></pre>

<p>The memory allocated to p_someClass is deallocated as soon as f() goes out of scope.
However, what if getSomeclass() doesn't allocate new memory but simply return a "singleton" pointer (and p_Helper is also singleton)? Then the next call to p_Helper->getSomeclass() will be in trouble.</p>

<p>What is the usual way to handle this issue, esp when there is very little documentation on the Helper class?</p>
