title: How to overload the arrow dereference operator->() not for solid objects but for pointers
body: <p>I know how to overload operator-> for solid (stack) objects (like smart pointers)</p>
  
  <pre><code>#include &lt;iostream&gt;
  struct A { void foo() {} };
  struct B {
      A* pa;
      A* operator-&gt;() {
          return pa;
      }
  };
  int main() {
      B b;
      b-&gt;foo();  // b is SOLID object on stack: b.pa = ...
  }
  </code></pre>
  
  <p>But I want this:</p>
  
  <pre><code>B * pb = new B();
  pb-&gt;foo(); // to call my overload
  </code></pre>
  
  <p>I need this for the Database Manager Singleton design:</p>
  
  <pre><code>class DatabaseManager
  {
  private:
      static DatabaseManager * sharedInstance_;
      sqdb::Db *db = nullptr;
  
  public:
      static DatabaseManager * instance();
      sqdb::Db * operator-&gt;() {
          return db;
      }
  }
  </code></pre>
  
  <p>I want basically this behavior</p>
  
  <pre><code>auto m = DatabaseManager::instance();
  m-&gt;Query(...); // db-&gt;Query 
  </code></pre>