Multiple inheritance and a broken super() chain

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Jul 4 20:26:35 EDT 2023


On 5/07/23 10:33 am, Alan Gauld wrote:
> (*) C++ is the odd one out because it doesn't have GC, but then
> neither does it have an Object superclass so very often MI in C++
> does not involve creating diamonds! And especially if the MI
> style is mixin based.

Even if all your mixins have empty constructors, in C++ there
is still a diamond problem if they have any data members, because
you end up with multiple copies of them.

But C++ has the concept of virtual base classes, which avoids the
diamond problem, albeit at the expense of making you explicitly
call all the base class constructors in your ancestry.

-- 
Greg







More information about the Python-list mailing list