Questions tagged [multiple-inheritance]

A feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass or base class.

Filter by
Sorted by
Tagged with
-3 votes
0 answers
22 views

Is there a performance difference between single inheritance and multiple inheritance in Python? [closed]

In object-oriented programming, inheritance is a fundamental concept where a class (referred to as a subclass or derived class) inherits properties and behaviors (methods and attributes) from another ...
Tabish Farhan's user avatar
0 votes
1 answer
45 views

Is there any reason to do to multiple inheritance with object?

While reviewing some code, it has a structure like class Bar(Foo, object): Which seems like it could easily be written instead as class Bar(Foo): The functionally appears at least the same the ...
ti7's user avatar
  • 16.8k
0 votes
1 answer
64 views

How to solve multiple class inheritance without duplicating code in my case?

My concrete classes can be one of the type permutations shown below. But, since I cannot inherit from two classes (case 4 and 5) I had to convert one of them to interface which introduce code ...
theateist's user avatar
  • 14k
0 votes
0 answers
19 views

How to deal with class __init__ method that generate from type() function? [duplicate]

I write a class C generate from type, it can use; but when I write another class D inherit from C, an error that miss required positional argument occurred. so, I tried to use normal inherit way to ...
Chuan Smith's user avatar
1 vote
0 answers
19 views

ImmutableDict implementation doesn't call __setitem__

In the code below I create a class ImmutableDict that appears to have a __setitem__ implementation that should throw an exception, but it doesn't. Why not? from typing import Mapping, TypeVar KT = ...
Captain_Obvious's user avatar
2 votes
1 answer
47 views

Can a merge relation in a UML-Package Diagram lead to multiple inheritance?

I wonder whether the use of the merge-relation in an UML package diagram might lead to multiple inheritance. Specifically, I was thinking about the following situation: A package containing a class ...
BranAndSceolan's user avatar
1 vote
1 answer
41 views

Scala trait linearization equivalent in Kotlin

I'm migrating some Scala code to Kotlin, that uses method linearization in a hierarchy of clasess and interfaces (traits in Scala jargon). Does Kotlin have something equivalent? Any workaround? https:/...
david.perez's user avatar
  • 6,314
0 votes
0 answers
50 views

Correct way to use multiple inheritance with Qt (pysyde6)

I'm trying to use multiple inheritance with my and Qt-derived classes. But faced with the fact that the __init__() method from my class is not called when I use super() to call __init__() for base ...
GrAnd's user avatar
  • 10.2k
-1 votes
1 answer
69 views

JPA multiple inheritence

I've this kind of data model: @Entity @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public class Operaton { @Id private int id; } @Entity public class Payment extends Operaton { ...
Ludov Dmitrii's user avatar
0 votes
1 answer
40 views

How to pass an subclass argument to another subclass in multiple inherited class in python?

I'm trying to use multiple inheritance and I don't know if it's just me using it badly or if there's a clean way to do what I'm trying to do. Here's my code : class B: def __init__(self, b_x: int, ...
tenup's user avatar
  • 53
5 votes
2 answers
116 views

clang 18 and operator overloads from multiple bases

I have upgraded clang from ver 14 to the latest one (18 on trunk) and it seems the only problem I have in my code is operator inheritance from multiple base classes (an example and reference to ...
Konstantin Lazukin's user avatar
0 votes
1 answer
29 views

python - "Extending" multiple classes with inheritance/decorators that works with code completion

I have multiple classes, let's say OrigClass1 to OrigClass100 from an external package. I want to "extend" them, that is add the same set of attributes and methods to each one of them. I ...
yassem's user avatar
  • 61
1 vote
1 answer
65 views

Multiple inheritance from classes sharing a parent

Is it possible to inherit from multiple classes that share a parent? class A: def __init__(self, a1, a2='a2'): self.a1=a1 self.a2=a2 def report(self): print('...
bhumm's user avatar
  • 45
0 votes
0 answers
46 views

How to construct a Python object with multiple inheritance? [duplicate]

I succeeded to construct a Python object with multiple inheritance but I feel like I didn't use the proper way... Here is my code : class A: def __init__(self, a): print("A ctor ...
Autechre's user avatar
  • 512
0 votes
0 answers
30 views

Python: Nested Inheritance, unable to add argument to a "grand-child" class

I can't figure out why I can't add additional arguments to a "grandchild" class "Rival". In order to be able to add an arg group to the grandchild class "Rival". I have ...
Paul Buencamino's user avatar
0 votes
1 answer
68 views

Why a Class which implements a Comparable Interface is not Comparable?

To generalize the question If Interface A is Comparable, Class B extends Interface A. And for Class C the type parameter it takes must be comparable. For class A public interface A extends Comparable&...
Daybreak Texas's user avatar
0 votes
1 answer
41 views

How to make generic class inheriting from TypeVar in Python?

How can I create a Generic class in Python, that has the TypeVar as a base class? The minimum example is this: from typing import TypeVar, Generic T = TypeVar("T") class A(T, Generic[T]): ...
Petr's user avatar
  • 498
0 votes
1 answer
76 views

solve field ambiguity in multiple inheritance C++ [duplicate]

I was checking out inheritance and got a field ambiguity compile-time error. Here is my code: #include<iostream> class Base { public: int a; }; class Derived1: Base {}; class Derived2: ...
Manuel's user avatar
  • 15
0 votes
0 answers
33 views

What is the correct way to implement this dynamic inheritance-like structure in Python?

I'm implementing part of a test library for a web tool. The user (or in this case, the test) interacts with the web tool through "sessions". There are certain steps the test must take to ...
Logan Kirkland's user avatar
1 vote
0 answers
87 views

Multiple inheritance check if same object if only base classes are given

I have a method which takes two objects (which are not directly related to each other). Is it possible to check if the two objects are derived from the same object? Given the following two interfaces ...
Leitwert's user avatar
0 votes
0 answers
30 views

Confusing super keyword in multiple inheritance [duplicate]

I have two code blocks, which I believe is the same, but they result in different output. Code block 1 class GP: def __init__(self): print("GP") class P1(GP): def __init__(...
Yogesh's user avatar
  • 699
-1 votes
1 answer
65 views

What are rules of comparing pointer to superclass with pointer to subclass?

Simple definition: class B1 { /* stuff, virtual methods */ }; class B2 { /* stuff, virtual methods */ }; class D : public B1, public B2 { /* stuff, overrides*/ }; Some variables: D obj; B1 *bp1 = ...
hyde's user avatar
  • 61.1k
2 votes
1 answer
71 views

How can i combine multiple class names to one keyframe in css

i'm trying to make some animation for two different classes without repeating the @keyframes properties. such that the classes will be styled differently while the keyframes animation properties ...
Nelson Ndiy's user avatar
2 votes
0 answers
67 views

The correct mental model for diamond inheritance in C++

I am trying to understand how the sizes of derived objects are constructed, especially in the case of diamond inheritance, and how virtual inheritance works. Example of a diamond inheritance: class A {...
Ahmed Waleed's user avatar
3 votes
1 answer
68 views

How does polymorphism with multiple inheritance work in assembly?

so I believe I understand polymorphism with single inheritance, where say you have classes Dog and Cat inherit from an interface Animal and Animal has a Speak and Walk function so then you generate v ...
IrrelevantGaymer 's user avatar
0 votes
1 answer
31 views

What is the point of calling super from base(root) class in this multiple inheritance example?

This is the code I am trying to run which is trying to calculate area of the right pyramid using the concept of multiple inheritance in Python class Rectangle: def __init__(self, length, width, **...
humanoid's user avatar
-1 votes
1 answer
62 views

change the variables in the __init__ method of inherited classes

I am trying to change default value of "seed" which is inside __init__ method after I built an instance of a class which inherited from other classes. I have "Environment" class ...
Dalek's user avatar
  • 4,198
2 votes
3 answers
110 views

Using multiple inheritance, getting "TypeError: __init__() missing 1 required positional argument" [duplicate]

Here is my code. Which is an exmaple of multiple inheritances in pyton. But it shows an error. I want to create a program where single inheritance and multiple inheritance will be used. To do this, ...
Arup Bhattacharya's user avatar
1 vote
0 answers
29 views

Python multiple inheritance accessing all inherited attributes

I am trying to wrap my head around multiple inheritance and contrived a very simple example that is not able to access all of the inherited attributes. This may or may not be possible, but if so I ...
Frac's user avatar
  • 331
1 vote
1 answer
55 views

removing overhead of dynamic_cast codegen with minimum boilerplate

How can I obtain all necessary information in order to print an equivalent faster string of code for "dynamic_cast<B&>(p)->eval()" at run-time from the code below? (please find ...
user avatar
0 votes
2 answers
60 views

Cast qualifier to "TrainEngine" meaning?

I am New to Java and OOPs Concepts, I am having trouble with this. I have this function in the Train Class (it associates the TrainCar Class) in which I am running a for loop to loop through an array ...
Saurav Prashar's user avatar
0 votes
0 answers
63 views

Python multiple inheritance with same methods

I have a Time class and a Date class as parent classes , and both of them has the get() method which is Time class gets h/m/s and Date class gets y/m/d . I have Invoice class as child class that ...
Alien's user avatar
  • 19
1 vote
2 answers
48 views

Perl multiple inheritance, inheriting the same method name twice: How to use the right method correctly?

Well, I shouldn't use Perl using multiple inheritance, but I did. Consider the following code sketch ($self denotes the current object): package A; sub f { ... } sub _init { ...; $self->f; ... } ...
U. Windl's user avatar
  • 3,637
1 vote
0 answers
35 views

How to achieve multiple inheritance with custom classes derived from Microsoft UserControl class?

I'm writing a Word VSTO add-in that displays a Microsoft CustomTaskPane (CTP). At runtime, when you create a CustomTaskPane, you must first instantitate a Microsoft UserControl (UC) and provide it to ...
VA systems engineer's user avatar
1 vote
2 answers
97 views

super() in inherited class that will be inherited with multiple inheritance

If one has a class that inherits, and uses super() to refer to the parent class, and then inherits from that class using multiple inheritance, super() gets confused and no longer looks at the current ...
Mordechai's user avatar
  • 148
0 votes
2 answers
79 views

How to write let two Python abstract classes implement each other's abstract methods?

Suppose you have abstract classes A1 and A2. Each of them has an abstract method and a concrete method. from abc import ABC, abstractmethod class A0(ABC): pass class A1(A0, ABC): def foo(...
Yang Bo's user avatar
  • 3,612
-9 votes
1 answer
110 views

Why is my code is not working as expected? [closed]

In the output, there was an error when I attempted to display it. The output is displayed without any errors, but the total marks and percentages are not displayed. I would appreciate if anyone could ...
Krinesh Vasava's user avatar
0 votes
0 answers
38 views

Populate arraylist with object from different classes

I have the following classes: parent class CandyBox which has arguments private String flavor and private String origin + method getVolume() which return 0 3 children classes of CandyBox: A, B and C -...
Aled's user avatar
  • 1
1 vote
0 answers
29 views

Multiple Inheritance and Wrappers in Python

Apologies for the noob question, but a bit confused by inheritance and wrapper classes in Python and hoping for input. I'm familiar with this pattern for inheritance in Python: from api.client import ...
Chris's user avatar
  • 1,400
0 votes
1 answer
31 views

Why is the initialiser of the inherited class skipped? [duplicate]

While setting up a class hierarchy that involves multiple inheritance I came across problems with the order of constructor/initialiser calls. To help me analyse I set up a minimal, contrived example ...
twil's user avatar
  • 83
2 votes
2 answers
78 views

What is the relation between the Lookup Chain and MRO in Python?

In Python, I've come across two concepts, the Lookup Chain and the Method Resolution Order (MRO), which seem related but I'm having trouble understanding their relationship. Could someone please ...
Suyog Shimpi's user avatar
0 votes
2 answers
42 views

Multiple Inheritance -> Interface1 reference calling methods of another interface2 in C#

//Interface I1 and I2 I cant change as they are public interface I1 { void Display(); } public interface I2 { void Display(); void Display2(); } //I can make changes here public class ...
Rushee's user avatar
  • 766
1 vote
1 answer
41 views

How can I get a class using multiple inheritance to call all parents' init methods with arguments?

In my program, I am using abstract base classes to force subclasses to have certain attributes and/or behavior. I am aware this is not particularly pythonic, but the complexity of my code doesn't lend ...
DarkNetFan's user avatar
0 votes
1 answer
134 views

Multiple inheritance of two classes with same field

I guess for the python experts this is a simple one... but maybe someone can explain me. imagine we have two classes with the same field: class A: name = 'a' class B: name = 'b' and now we ...
Matthias Burger's user avatar
-3 votes
2 answers
54 views

Multiple child class vs Single child class - Java Inheritance

I have a question that extending a Parent class to multiple child classes is a good practice or maintaining a single child is a good practice? Does this affects the scalability? All the classes will ...
S14321K's user avatar
  • 220
-1 votes
2 answers
159 views

How to delete constructors and operators using inheritance in c++?

Suppose I have two classes, no_copy and no_move which are base classes. From which any class can derive from and hence have their constructors and operators modified. As the name suggests, no_copy ...
Amrit Sanjeev's user avatar
2 votes
1 answer
53 views

Multiple Inheritance in Python calling parent methods giving confusing output

Multiple Inheritance in Python calling parent methods class A: def m(self): print(f"m of A called") class B(A): def m(self): print("m of B called") ...
sbooyah's user avatar
  • 23
0 votes
1 answer
18 views

How to resolve 'HybridVehicle.__init__() missing 1 required positional argument' in Python 3.x?

Created a Base class 'Vehicle' having attributes make, model, and year class Vehicle: def __init__(self, make, model, year): self.make = make self.model = model self.year ...
Tanveer Ahmad's user avatar
0 votes
1 answer
62 views

How to make (only) the main path virtual in the diamond problem

This code does not compile: #include <iostream> class BaseV1 { public: BaseV1(int i = 0) { std::cout << i; } void foo() {} }; class DataV1 : public BaseV1 { public: ...
bers's user avatar
  • 4,944
0 votes
2 answers
155 views

Python Multiple Inheritance Diamond Problem

I have a diamond inheritance scenario. The two middle classes inherit okay, but the Combo class, I can't quite figure out. I want the Combo class to inherit all attributes with the overridden methods ...
Harley's user avatar
  • 1,375

1
2 3 4 5
55