title: C++ overloading dereference operators
body: <p>I'm relatively new to C++, still trying to get a hang of the syntax. I've been taking a look at a few operator overloading examples, most recently smart pointer implementations. Here's a really generic example I'm looking at:</p>
  
  <pre><code>template &lt; typename T &gt; class SP
  {
      private:
      T*    pData; // Generic pointer to be stored
      public:
      SP(T* pValue) : pData(pValue)
      {
      }
      ~SP()
      {
          delete pData;
      }
  
      T&amp; operator* ()
      {
          return *pData;
      }
  
      T* operator-&gt; ()
      {
          return pData;
      }
  };
  </code></pre>
  
  <p>When overloading the dereference operator why is the type T&amp;? Similarly, when overloading the structure dereference why is the type T*?</p>