[C++-sig] Confusion about inheritance with boost.python

David Abrahams dave at boost-consulting.com
Wed Oct 4 12:49:31 CEST 2006


David Abrahams <dave at boost-consulting.com> writes:

> Noah Schwartz <noah.schwartz1 at gmail.com> writes:
>
>> struct AWrap : A, wrapper<A> {
>> 	int f() {
>> 		return 0;
>> 	}
>> };
>>
>> BOOST_PYTHON_MODULE(libnn)
>> {
>> 	class_<AWrap, boost::noncopyable>("A")
>> 		.def("f", pure_virtual(&A::f))
>> 		;
>> }
>
> This doesn't look right.  If A::f is supposed to be exposed as pure
> virtual, you shouldn't be overriding it in AWrap.

Sorry, I don't know what I'm saying.  AWrap should say:

       int f()
       {
            return get_override("f")();
       }

but of course that has nothing to do with your problem.

>> However when I load my module in python I get a complaint about the
>> undefined symbol A.
>
> Please post the complete text of the complaint.  In fact, please also
> post a reproducible example containing one C++ file and one Python
> file.
>
> -- 
> Dave Abrahams
> Boost Consulting
> www.boost-consulting.com

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




More information about the Cplusplus-sig mailing list