C++ -- Why should we use operator -> to access member functions of a SmartPtr?
<p>The question is given in the last two lines of code.</p>

<pre><code>template&lt;class T&gt;                    // template class for smart
class SmartPtr {                     // pointers-to-T objects
public:
  SmartPtr(T* realPtr = 0);

  T* operator-&gt;() const;
  T&amp; operator*() const;

  T* Detach( void )
  {
    T* pData = pointee;
    pointee = NULL;
    return pData;
  }  

private:
  T *pointee;
  ...
};

class TestClass {}

SmartPtr&lt;TestClass&gt; sPtr(new TestClass);

TestClass* ptrA = sPtr-&gt;Detach();
// why I always see people use this method to access member functions of a Smart pointer.
// We can use sPtr-&gt; b/c we have defined operator-&gt;() in SmartPtr.    

TestClass* ptrB = sPtr.Detach();  
// Question: Is this a valid C++ way? If not, why?
</code></pre>

<p>Thank you</p>
