[C++-sig] Polymorphism between Python and C++
Patrick Hartling
patrick at vrac.iastate.edu
Fri Nov 15 18:14:55 CET 2002
I'm doing some experimenting with Boost.Python v2, and I have run into a
problem I just can't seem to solve. I want to define an abstract base
class in C++, derive a Python class from that base, and then use the
derived Python class polymorphically where the abstract C++ class can be
used. I have attached the simplest code I could come up with that
demonstrates the problem. When I run test.py, I get the following output:
I'm Derived1!
Traceback (most recent call last):
File "./test.py", line 18, in ?
handler.setObj(derived2)
TypeError: bad argument type for built-in operation
I have been over the documentation (both on boost.org and on the
PythonInfo Wiki), but I can't figure out what I am doing wrong. It seems
like I am close, but there must be some detail I'm missing.
-Patrick
--
Patrick L. Hartling | Research Assistant, VRAC
patrick at vrac.iastate.edu | 2624 Howe Hall: 1.515.294.4916
http://www.137.org/patrick/ | http://www.vrac.iastate.edu/
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Simple.cpp
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20021115/e54fb427/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.py
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20021115/e54fb427/attachment-0001.txt>
More information about the Cplusplus-sig
mailing list