[C++-sig] Exporting an abstract class with virtual bool operator ()(int)=0

Achim H. achim-bpl at mol-net.com
Wed Mar 29 16:11:04 CEST 2006


Am Mittwoch, 29. März 2006 16:03 schrieb pedro:
> > IMHO, boost::python doesn't know that condition_Wrap is derived from
> > condition, you'd have to mention that in the class_<>() statement.
>
> Could you be more precise about this, please? How would you mention this
> ... I just followed the boost.python tutorial section about "Exposing
> Classes > Class Virtual Functions" and
> they proceed with class_<> in the way I do.

My suggestion is to write the following:

BOOST_PYTHON_MODULE(test2py)
{
    class_<condition_Wrap, bases<condition>, boost::noncopyable>("condition")
        .def("__call__", pure_virtual(&condition::operator()))
        ;

HTH,
Achim.



More information about the Cplusplus-sig mailing list