title: How can I remove multiple inheritance in this example?
body: <h2>Background</h2>
  
  <p>I have two abstract base classes, <code>ISolid</code> and <code>IBox</code> which define interfaces for a Solid and a Box, respectively:</p>
  
  <pre><code>using std::unique_ptr&lt;IFace&gt; pIFaces;
  using std::unique_ptr&lt;IEdge&gt; pIEdge;
  
  class ISolid
  {
      public:
          virtual const pIFaces&amp; getFaceVector() const = 0;
          virtual const pIEdges&amp; getEdgeVector() const = 0;
  };
  
  class IBox : public ISolid
  {
      public:
          virtual inline ~IBox() = default;
          virtual const IFace&amp; front() const = 0;
          virtual const IFace&amp; back() const = 0;
          virtual const IFace&amp; left() const = 0;
          virtual const IFace&amp; right() const = 0;
          virtual const IFace&amp; top() const = 0;
          virtual const IFace&amp; bottom() const = 0;
  };
  </code></pre>
  
  <p>Subsequently, I have defined a real implementation of ISolid, <code>Solid</code> as follows:</p>
  
  <pre><code>class Solid : public ISolid
      {
          public:
              Solid(const TopoDS_Solid&amp; aSolid);
              const pIEdges&amp; getEdgeVector() const override;
              const pIFaces&amp; getFaceVector() const override;
              const TopoDS_Solid&amp; getSolid() const;
  
          protected:
              TopoDS_Solid mySolid;
              pIEdges myEdges;
              pIFaces myFaces;
      };
  </code></pre>
  
  <p>Finally, I am attempting to define a real implementation of IBox as follows:</p>
  
  <pre><code>class Box : public Solid , public IBox
  {
      public:
          Box(BRepPrimAPI_MakeBox mkBox);
          ~Box(){};
  
          const pIFaces&amp; getFaceVector() const override;
          const pIEdges&amp; getEdgeVector() const override;
  
          const IFace&amp; front() const override;
          const IFace&amp; back() const override;
          const IFace&amp; left() const override;
          const IFace&amp; right() const override;
          const IFace&amp; top() const override;
          const IFace&amp; bottom() const override;
      private:
          BRepPrimAPI_MakeBox myMakeBox;
          std::map&lt;std::string, int&gt; myIndices;
  };
  </code></pre>
  
  <h2>Question</h2>
  
  <p>How can I change my design in order to avoid the multiple inheritance in <code>Box</code>? I would like to keep the <code>ISolid</code> and <code>IBox</code> interfaces, as this allows me pass around pointers or references to either an <code>ISolid</code> or <code>IBox</code> without caring about its actual implementation. Also, I have need to manipulate both solid objects and box objects. In other words, <code>OccSolid</code> cannot remain virtual.</p>
  
  <p>Is my best bet to remove the inheritance of <code>Solid</code> from <code>Box</code>, and add a member variable of type <code>Solid</code>? I would then have to add code that implements the missing methods from <code>ISolid</code> (inherited in <code>IBox</code>), and would subsequently have to do this for other <code>ISolid</code> inheritors (i.e. <code>ICylinder</code>, etc...) I would like to avoid this boilerplate if possible.</p>
  
  <h2>Options Considered</h2>
  
  <p>I have considered dropping the inheritance from <code>ISolid</code> altogether on <code>Box</code>, however I want/need a pointer/reference to an <code>ISolid</code> to be able to refer to either a <code>Solid</code> or a <code>Box</code>. This is because a <code>Box</code> <strong>is a</strong> <code>Solid</code>. I suppose I <em>could</em> duplicate the <code>ISolid</code> interface in <code>IBox</code> (and <code>ICylinder</code> etc...) but this would lead to parallel code bases in the I family of interfaces, and I'd like to avoid that.</p>
  
  <p>Finally, I have also considered using virtual inheritance in <code>IBox</code> and <code>Solid</code>, in order to solve the death diamond issue. The only problem I have with this approach is that something along the lines of the following code snippet doesn't appear to work:</p>
  
  <pre><code>using std::unique_ptr&lt;ISolid&gt; pISolid;
  pISolid MakeFusion(const pISolid&amp; shape1, const pISolid&amp; shape2)
  {
      const Solid&amp; solid1 = static_cast&lt;const Solid&amp;&gt;(*shape1);
      const Solid&amp; solid2 = static_cast&lt;const Solid&amp;&gt;(*shape2);
      return FusionOf(solid1.getSolid(), solid2.getSolid());
  }
  </code></pre>
  
  <p>You can see in this example that <code>shape1</code> could be a regular <code>Solid</code> while <code>shape2</code> could be a <code>Box</code> (a more specific type of solid). The compilation error I get with code like this is:</p>
  
  <pre><code>src/OccSolidMaker.cpp: In member function ‘virtual BKAL::pISolid Occ::SolidMaker::makeFusion(const pISolid&amp;, const pISolid&amp;) const’:
  src/OccSolidMaker.cpp:26:69: error: cannot convert from pointer to base class ‘BKAL::ISolid’ to pointer to derived class ‘Occ::Solid’ because the base is virtual
       const Occ::Solid&amp; occBase = static_cast&lt;const Occ::Solid&amp;&gt;(*base);
                                                                       ^
  OccSolidMaker.cpp:27:69: error: cannot convert from pointer to base class ‘BKAL::ISolid’ to pointer to derived class ‘Occ::Solid’ because the base is virtual
       const Occ::Solid&amp; occTool = static_cast&lt;const Occ::Solid&amp;&gt;(*tool);
  </code></pre>
  
  <hr>
  
  <p>Please note, this question is not specifically regarding this compilation error and as such I have not provided a minimal working example to reproduce it.</p>