Boost.Python 1.42 documentation shows how to overload virtual functions using 
boost::python::wrapper::get_override. I made the example work.<br>
<br>Now I am struggling with a inheritance problem with virtual functions calling each other, with a mix and match of Python and C++ implementation of a common base. <br><br>I saw that in the distribution&#39;s &quot;test&quot; directory, as well as in the paper &quot;Building Hybrid System with Boost.Python&quot;, call_method and boost::ref are used instead of wrapper::get_override.<br>

<br>What is the difference between the two approach ? Given a class hierarchy like the one below, wich road should I take ?<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">//Simplified C++ version</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">struct Base {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">    virtual int f() = 0;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    virtual void call_f(Base &amp;b) { this-&gt;f(); b.f(); } /* this pointer will always be specialized */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">struct BaseWrap : Base, /*should I inherit from wrapper here... */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     int f() {  /* or use call_method here ??? */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">struct Derived1 : Base /* or BaseWrap ? */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">{</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">   int f() { return 1; } </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">}</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">struct Derived2 : Base /* or BaseWrap ? */</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
{</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
   int f() { return 2; }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
}</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">#Extended in Pyhton</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class PyDerived1(Derived1):</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">    def f(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">        return -Derived1.f(self); #Calling the ancestor class is a requirement</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class PyDerived2(Derived2):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
    def f(self):</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">
        return -Derived2.f(self);  #Calling the ancestor class is a requirement</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#And called like this</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">py1 = PyDerived1()</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">py2 = PyDerived2()</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">py1.call_f(py2)</span><br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;">
<br>TIA,<br><br clear="all">--<br>Guillaume<br>