[C++-sig] Function taking Virtual Base Pointer
Thomas Muldowney
temas at box5.net
Fri Dec 13 00:41:33 CET 2002
If I take out the no_init I can no longer compile because of the
abstract member function. Perhaps I need to be using a CVS copy of
boost? Here is the complete error:
/opt/boost-gcc-3.2/include/boost/python/class.hpp: In constructor
`boost::python::detail::assert_default_constructible<T>::assert_default_constructible()
[with T = A]':
/opt/boost-gcc-3.2/include/boost/python/class.hpp:433: instantiated from `boost::python::class_<T, X1, X2, X3>::class_(const char*, const char*) [with T = A, X1 = boost::noncopyable, X2 = boost::shared_ptr<A_cb>, X3 = boost::python::detail::not_specified]'
testMOD.cpp:25: instantiated from here
/opt/boost-gcc-3.2/include/boost/python/class.hpp:101: cannot allocate an
object of type `A'
/opt/boost-gcc-3.2/include/boost/python/class.hpp:101: because the following
virtual functions are abstract:
testMOD.cpp:7: virtual void A::onCommand()
--temas
On Thu, Dec 12, 2002 at 06:10:18PM -0500, David Abrahams wrote:
> Thomas Muldowney <temas at box5.net> writes:
>
> > I'm trying to implement an event listener class from my C++ library so
> > that python scripts can override it and get the events delivered to them
> > in the script. After reading the docs it all seemed possible and easy
> > to do.
> <snip>
>
>
> > BOOST_PYTHON_MODULE(testMOD)
> > {
> > class_<A, boost::noncopyable,
> > boost::shared_ptr<A_cb> >("A", no_init);
> strike no_init here------------------^^^^^^^
> You don't really need shared_ptr; but it's OK.
>
> > def("test_Aptr", test_Aptr);
> > }
> >
> >
> > Python test script:
> > from testMOD import *
> >
> > class MyA(A):
> > ## Don't get yelled at because we pass off to the non existant internal
> > ## constructor
> > def __init__(self):
>
> You need to call the base class __init__ here to create the C++
> instance. Or you can do it the easy way; just remove the __init__
> function here.
>
> > pass
>
> > def onCommand(self):
> > print "We got a command"
> >
> > a = MyA()
> > test_Aptr(a)
> >
> > Output running it:
> > $ python test_ptr.py
> > Traceback (most recent call last):
> > File "test_ptr.py", line 12, in ?
> > test_Aptr(a)
> > TypeError: bad argument type for built-in operation
> >
> >
> > I really do love everything, this has just been giving me a headache =)
>
> I love everything too!
>
> --
> David Abrahams
> dave at boost-consulting.com * http://www.boost-consulting.com
> Boost support, enhancements, training, and commercial distribution
>
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20021212/7e52f8db/attachment.pgp>
More information about the Cplusplus-sig
mailing list