<div>I have a C++ class which is declared with pure virtual methods, but if I derive from this class in python and implement the pure virtual methods, I get an exception:</div><div>TypeError: pyvoip.opal.OpalPCSSEndPoint cannot be instantiated or sub-classed</div>
<div><br></div><div>My python class is declared as following:</div><div><br>class PCSSEndPoint(OpalPCSSEndPoint):<br> def __init__(self):<br> super(OpalPCSSEndPoint, self).__init__()<br> <br> def OnShowIncoming(self, connection):<br>
return True<br> <br> def OnShowOutgoing(self, connection):<br> return True<br> <br> def GetMediaFormats(self):<br> return []</div><div><br></div><div><br></div><div>SIP definitions:<br></div>
<div><br></div><div>class OpalPCSSEndPoint : OpalLocalEndPoint /Abstract/</div><div>{</div><div><br></div><div>/**Call back to indicate that remote is ringing.<br> If false is returned the call is aborted.<br><br> The default implementation is pure.<br>
*/<br> virtual PBoolean OnShowIncoming(<br> const OpalPCSSConnection & connection /NoCopy/ ///< Connection having event<br> ) = 0;<br><br> /**Call back to indicate that remote is ringing.<br> If false is returned the call is aborted.<br>
<br> The default implementation is pure.<br> */<br> virtual PBoolean OnShowOutgoing(<br> const OpalPCSSConnection & connection /NoCopy/ ///< Connection having event<br> ) = 0;<br></div><div><br>
</div><div>};</div><div><br></div><div>Now the base class of
OpalPCSSEndPoint
is also an ABC, as it derives from an ABC but does not re-define the pure virtual function:</div><div><br></div><div>class OpalLocalEndPoint : OpalEndPoint /Abstract/<br></div><div>{</div><div> ...</div><div>};</div><div>
</div><div>class OpalEndPoint /Abstract/</div><div>{</div><div>virtual OpalMediaFormatList GetMediaFormats() const = 0;</div><div>};</div><div><br></div><div>I tried removing /Abstract/ from OpalLocalEndPoint, but it made no difference.
Any idea what's wrong in this scenario? The only way this works, is if I subclass
OpalPCSSEndPoint
in C++ and then in Python create a class derived from my OpalPCSSEndPoint
subclass.</div><div><br></div>