[C++-sig] Overloaded pure virtual method
Mark Williams
mark at image-engine.com
Tue Oct 24 21:36:30 CEST 2006
Hi, I'm having some difficulty understanding the syntax for binding pure virtual member functions with default arguments. Here
is a simple class definition:
class TestOverloads
{
public:
virtual ~TestOverloads() {}
virtual void overloaded(float f = 0) =0;
};
I have also defined:
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MyOverloads, overloaded, 0, 1);
Now, I find that the following does not compile:
class_<TestOverloads, boost::noncopyable>("TestOverloads", no_init)
.def("overloaded", pure_virtual( &TestOverloads::overloaded), MyOverloads() );
But the following does compile:
class_<TestOverloads, boost::noncopyable>("TestOverloads", no_init)
.def("overloaded", pure_virtual( &TestOverloads::overloaded) );
If I remove the =0 pure virtual specification from the class definition then I can at least compile:
class_<TestOverloads, boost::noncopyable>("TestOverloads", no_init)
.def("overloaded", &TestOverloads::overloaded, MyOverloads() );
So it would appear to be some combination of pure_virtual with BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS
What am I doing wrong here, please?
Thanks,
Mark
More information about the Cplusplus-sig
mailing list