[C++-sig] Re: pure virtual methods with pyste

David Abrahams dave at boost-consulting.com
Mon Jul 28 13:48:56 CEST 2003


wiedeman at gmx.net writes:

> Hi Nicodemus,
>
>>Yes, it follows the procedure in the tutorial about abstract virtual 
>>functions, ie, it only generates the virtual wrapper. You should still 
>>be able to override the abstract member functions in Python, though... 
>>is this the problem you're having?
>
> No, that's not my problem. I want to be able to use pointers to abstract
> classes within python without wrapping all the derived classes (in fact, they
> are plugins), and, if possible, without writing a call_f function for every
> pure virtual method. 
> I've played around with boost.python and found the solution below
> (Test.cpp). With pyste, i'd get an empty class Abstract. I wonder, if my solution is
> dangerous or even wrong ?
>
> Thanks in advance,
> Christoph
>
> /* Test.cpp */
>
> struct Abstract { 
>   virtual void a() = 0;
> };
>
> #include <boost/python.hpp>
>
> using namespace boost::python;
>
> BOOST_PYTHON_MODULE(myclasses) {
>   class_<Abstract, AbstractWrap, boost::noncopyable>("Abstract")
                     ^^^^^^^^^^^^
This part is wrong.
>     .def("a", &Abstract::a)
>     ;
> }

http://aspn.activestate.com/ASPN/Mail/Message/c++-sig/1748053

I'm not sure why people keep doing that; perhaps we need to fix the
tutorial somehow?  If you can, Christoph, it would be a big help if
you could explain why you thought that was the right thing to do.

Thanks,
Dave

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list