CCing mailing list<br><br><div class="gmail_quote">On Sat, Jul 2, 2011 at 10:50 PM, Demetrius Cassidy <span dir="ltr"><<a href="mailto:dcassidy36@gmail.com">dcassidy36@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Sat, Jul 2, 2011 at 10:45 PM, Phil Thompson <span dir="ltr"><<a href="mailto:phil@riverbankcomputing.com" target="_blank">phil@riverbankcomputing.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

On Sat, 2 Jul 2011 17:39:14 +0000, Demetrius Cassidy<br>
<<a href="mailto:dcassidy36@gmail.com" target="_blank">dcassidy36@gmail.com</a>><br>
wrote:<br>
<div>> I have a C++ class which is declared with pure virtual methods, but if I<br>
> derive from this class in python and implement the pure virtual methods,<br>
I<br>
> get an exception:<br>
> TypeError: pyvoip.opal.OpalPCSSEndPoint cannot be instantiated or<br>
> sub-classed<br>
><br>
> My python class is declared as following:<br>
><br>
> class PCSSEndPoint(OpalPCSSEndPoint):<br>
>   def __init__(self):<br>
>   super(OpalPCSSEndPoint, self).__init__()<br>
<br>
</div>That should be super(PCSSEndPoint, self).__init__()<br></blockquote><div><br></div></div><div> 
The super thing was a typo. </div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div><br>
> def OnShowIncoming(self, connection):<br>
> return True<br>
><br>
> def OnShowOutgoing(self, connection):<br>
> return True<br>
><br>
> def GetMediaFormats(self):<br>
>   return []<br>
><br>
><br>
> SIP definitions:<br>
><br>
> class OpalPCSSEndPoint : OpalLocalEndPoint /Abstract/<br>
> {<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 OnShowIncoming(<br>
> const OpalPCSSConnection & connection /NoCopy/ ///< Connection having<br>
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<br>
event<br>
> ) = 0;<br>
><br>
> };<br>
><br>
> Now the base class of OpalPCSSEndPoint is also an ABC, as it derives<br>
from<br>
> an<br>
> ABC but does not re-define the pure virtual function:<br>
><br>
> class OpalLocalEndPoint : OpalEndPoint /Abstract/<br>
> {<br>
>   ...<br>
> };<br>
><br>
> class OpalEndPoint /Abstract/<br>
> {<br>
> virtual OpalMediaFormatList GetMediaFormats() const = 0;<br>
> };<br>
><br>
> I tried removing  /Abstract/ from OpalLocalEndPoint, but it made no<br>
> difference.  Any idea what's wrong in this scenario? The only way this<br>
> works, is if I subclass OpalPCSSEndPoint in C++ and then in Python<br>
create a<br>
> class derived from my OpalPCSSEndPoint subclass.<br>
<br>
</div></div>/Abstract/ is the cause of the problem. It doesn't mean that the C++ is an<br>
ABC, it means that the class contains other (unspecified) abstract methods.<br>
<font color="#888888"><br>
Phil<br></font></blockquote><div><br></div></div></div><div>So if /Abstract/ does not mean the class has pure virtual methods and cannot be instantiated itself, in which scenario should it be used? I'm a little confused here.</div>

<br>
</blockquote></div><br>