multiple-inheritance Questions

7

Solved

Do interfaces solve the deadly diamond of death problem? I don't think so, for example: // A class implementing two interfaces Interface1 and Interface2. // Interface1 has int x=10 and Interface2...
Permanganate asked 25/3, 2012 at 14:14

3

Solved

I have two classes A and B, where B is a subclass of A. I need both classes to use std::enable_shared_from_this. I tried this: #include <memory> #include <iostream> #include <vecto...

10

Solved

Consider the following example. The example is contrived but illustrates the point in a runnable example: class MultiplicatorMixin: def multiply(self, m: int) -> int: return self.value * m ...
Changsha asked 20/8, 2018 at 12:2

18

Solved

I've come to a point where I need to have some sort of rudimentary multiple inheritance happening in JavaScript. (I'm not here to discuss whether this is a good idea or not, so please kindly keep t...
Vintage asked 6/2, 2012 at 16:19

1

Solved

It is not very rare to find a library that zeros its objects in the constructors using memset. And sometimes it happens to empty classes as well. Is it safe, especially when one inherits such class...

3

Solved

I know virtual inheritance is covered here before and before asking this question, I went through the detail of the virtual inheritance and went through the details of a similar problem like the fo...

9

Solved

Java is not allowing inheritance from multiple classes (still it allows inheritance from multiple interfaces.), I know it is very much inline with classic diamond problem. But my questions is why j...
Sirocco asked 11/8, 2009 at 19:36

4

Solved

From the pydantic docs I understand this: import pydantic class User(pydantic.BaseModel): id: int name: str class Student(pydantic.BaseModel): semester: int # this works as expected class Stu...
Ortego asked 23/10, 2020 at 6:58

1

Solved

Two mixin classes specify requirements as abstract methods. Together, the classes have a full set of concrete methods. However, they fail to combine into a concrete class: no matter which order I u...

4

Solved

In Python, how do I pick which Parent's method to call? Say I want to call the parent ASDF2's __init__ method. Seems like I have to specify ASDF1 in the super()..? And if I want to call ASDF3's __i...
Privileged asked 7/1, 2013 at 23:40

3

Solved

I am trying to create a simple abstract base class Abstract that along with its own methods provides the methods of two others abstract base classes: Publisher and Subscriber. When I try to initial...
Tenantry asked 3/1, 2021 at 9:50

3

Solved

Let's say there are base_a.html, base_b.html, a.html, b.html, c.html. a.html extends base_a.html and b.html extends base_b.html. And c.html has to extend both base_a.html and base_b.html. It will...

3

Solved

Consider the following python code: class Parent(object): def __init__(self, name, serial_number): self.name = name self.serial_number = serial_number class ChildA(Parent): def __init__(self...

3

Solved

I'm trying to use the new python dataclasses to create some mix-in classes (already as I write this I think it sounds like a rash idea), and I'm having some issues. Behold the example below: from d...

3

Solved

Recently I have been trying to make a plugin for an old game, and running into a problem similar to Diamond Inheritance. I have a very reduced example, write as follows: #include <iostream> #...

18

Solved

In Programming Python, Mark Lutz mentions the term mixin. I am from a C/C++/C# background and I have not heard the term before. What is a mixin? Reading between the lines of this example (which I h...
Cleric asked 10/2, 2009 at 18:50

3

Solved

Let's say there are following types: public interface Base { default void sayHi(){ System.out.println("hi from base"); } } public interface Foo extends Base { @Override default void sayHi()...
Syriac asked 12/5, 2016 at 20:59

3

Solved

I am trying to dynamically create classes in Python and am relatively new to classes and class inheritance. Basically I want my final object to have different types of history depending on differen...
Dhow asked 16/9, 2015 at 1:38

1

Solved

I have a program which uses a custom allocator and deallocator to manage memory. I've recently encountered a leak that has lead me down a huge rabbit hole that end with custom deleters being incapa...
Periotic asked 1/9, 2022 at 19:5

4

Solved

We know that we can solve the diamond problem using virtual inheritance. For example: class Animal // base class { int weight; public: int getWeight() { return weight;}; }; class Tiger : p...
Senseless asked 12/9, 2011 at 6:0

6

Solved

UPDATE: I am not alone in my pondering on this issue and it seems it is indeed a bug. See here. The day it is fixed is going to be a fantastic day! :) This started out as I love PHP traits! I'm ...
Albie asked 4/12, 2013 at 17:41

4

Solved

I'd like to use a Mixin to always add some init functionality to my child classes which each inherit from different API base classes. Specifically, I'd like to make multiple different child classes...
Lucilucia asked 23/5, 2011 at 14:57

3

Solved

I have this code: class Person: def __init__(self, name, last_name, age): self.name = name self.last_name = last_name self.age = age class Student(Person): def __init__(self, name, last_name...
Slacks asked 19/5, 2022 at 5:22

9

Solved

http://en.wikipedia.org/wiki/Diamond_problem I know what it means, but what steps can I take to avoid it?
Friedafriedberg asked 26/9, 2008 at 1:36

3

Solved

Synopsis How can I safely design a move constructor when a class uses multiple inheritance? Details Consider the following scenario: struct T { }; struct U { }; struct X : public T, public U {...

© 2022 - 2025 — McMap. All rights reserved.