AutoPointer with objects not allocated on heap
<p>Auto pointer internally calls delete on the object that it points to once it goes out of scope. This works fine if we assign an object that is created on the heap. But if i try to assign an object that's not created on heap it crashes as delete is called twice. First by the auto_ptr itself and second as the object goes out of scope its destructor is called again. 
As shown below,</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;memory&gt;

using namespace std;

class sample
{
      public:
             sample() { puts("sample"); }
             ~sample() { puts("~sample"); }
};

int main()
{
    sample sObj;
    auto_ptr&lt;sample&gt; samplePtr(&amp;sObj);
}
</code></pre>

<p>Does that mean we can use auto_ptr to hold only the objects that are created on the heap?</p>
