title: Interface methods and returning smart pointer to this (enable_shared_from_this)
body: <p>I have a class (<code>Geometry</code>) that implements an interface (<code>LinkList</code>).  The code at the bottom of my example is obviously wrong, so I'm looking at implementing <code>std::enable_shared_from_this</code>.  Can <code>Geometry</code> safely inherit from <code>std::enable_shared_from_this&lt;LinkList&gt;</code> and can I safely change the <code>getLinkList()</code> method to <code>shared_from_this()</code>?  What happens if my <code>Geometry</code> class has multiple interfaces that it inherits, can I do this for all of the interfaces?</p>
  
  <pre><code>class Link
  {
  public:
      std::string getName() { return "the name"; }
  };
  class LinkList
  {
  public:
      virtual Link* getLink(int id) = 0;
      virtual int size() = 0;
  };
  class Geometry : LinkList
  {
  private:
      int state;
  public:
      void doSomething() { state = 1; }
      virtual Link* getLink(int id) { return new Link(); }
      virtual int size() { return 1; }
      std::shared_ptr&lt;LinkList&gt; getLinkList() { return std::shared_ptr&lt;LinkList&gt;(this); }
  };
  
  void printList(std::shared_ptr&lt;LinkList&gt; linkList)
  {
      for (int i = 0; i &lt; linkList-&gt;size(); i++)
      {
          std::cout &lt;&lt; linkList-&gt;getLink(i)-&gt;getName() &lt;&lt; std::endl;
      }
  }
  
  void main()
  {
      Geometry* geom = new Geometry();
      printList(geom-&gt;getLinkList());
      geom-&gt;doSomething(); // Error here
  }
  </code></pre>