[C++-sig] Re: Inheritance interoperability with other class systems
David Abrahams
dave at boost-consulting.com
Mon Sep 13 17:31:03 CEST 2004
Jonathan Brandmeyer <jbrandmeyer at earthlink.net> writes:
> I want to make a new class in Python that inherits from both a
> Boost.Python class and a class from the PyGTK library. Unfortunately, I
> get an exception:
>
> TypeError: multiple bases have instance lay-out conflict
>
> when the interpreter executes my Python class statement. Every instance
> of this exception that I have found via Google was caused due to one
> base class in each inheritance hierarchy having a __slots__ member
> defined, but that isn't the case here. What could be the cause of this
> error?
It's just what the message says: instances of C++ classes wrapped by
Boost.Python have a layout that's defined in
boost/python/object/instance.hpp. PyGTK probably has some other
instance layout.
I suggest using aggregation and delegation to simulate inheritance of
one of the classes. This is not fundamentally a Boost.Python
problem; it's kinda built in to the nature of Python.
--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com
More information about the Cplusplus-sig
mailing list