title: Clarification on smart pointer's operator* and operator-> overloading
body: <p>it's passed a lot since i used c++ so here the(probally dumb) question:</p>
  
  <p>A basic smart pointer Object should behave like a normal pointer one, so in a typical implementation we add the <code>*</code> and <code>-&gt;</code> operator to the object, something like this:</p>
  
  <pre><code>template &lt;class T&gt; class auto_ptr
  {
      T* ptr;
      public:
      explicit auto_ptr(T* p = 0) : ptr(p) {}
      ~auto_ptr()                 {delete ptr;}
      T&amp; operator*()              {return *ptr;}
      T* operator-&gt;()             {return ptr;}
     // ...
  };
  </code></pre>
  
  <p>Now, in my knowings, the c++ <code>*</code> operator (dereference) stands for: "get the value pointed in the heap by the value of ptr" (is it right?), and the type of <code>*ptr</code> should be <code>T</code>. So why we would return an address?</p>
  
  <pre><code>T&amp; operator*()              {return *ptr;}
  </code></pre>
  
  <p>Instead of:</p>
  
  <pre><code>T operator*()              {return *ptr;}
  </code></pre>
  
  <p>Second, by having the following snippet:</p>
  
  <pre><code>void foo()
  {
      auto_ptr&lt;MyClass&gt; p(new MyClass);
      p-&gt;DoSomething();
  }
  </code></pre>
  
  <p>Now, how can i access <code>ptr-&gt;DoSomething()</code> method by just writing <code>p-&gt;DoSomething()</code>? Logically i would come writing the wrong code:</p>
  
  <pre><code>p-&gt;-&gt;DoSomething();
  </code></pre>
  
  <p>Because <code>p-&gt;</code> returns a <code>T*</code> and then i need another <code>-&gt;</code> operator for access the <code>DoSomething()</code> method.</p>
  
  <p>Thanks for any answer/clarification and sorry for eventually bad English.</p>