2,757 questions
4
votes
1
answer
2k
views
How do I call an indirect parent class's method from a child class in Python? [duplicate]
I have classes A, B, and C. C inherits both from A and B, and for the most part wherever there are methods overriding each other I want A's to override B's, so I have the following structure:
class A:
...
0
votes
2
answers
1k
views
Can you suggest an good alternative for multiple inheritance in this case?
Summary: The case below involves using multiple inheritance for inheriting both an extended interface, and implementation for a basic interface.
I used virtual multiple inheritance to put in place the ...
1
vote
1
answer
71
views
Not calling the appropriate constructor
#include<iostream>
using namespace std;
class String
{
protected:
enum {SZ= 80};
char str[SZ];
public:
String (){str[0]='\0';}
String(char s[])
{
...
2
votes
1
answer
217
views
Python: multiple inheritance and properties
I've been working on a client/server TCP application of which here's a rough outline:
config_type = namedtuple('config', ['host', 'port'])
class Server:
def __init__(self, config: config_type):
...
0
votes
1
answer
494
views
Unable to access the member variables from second parent class in multiple inheritance Python [duplicate]
I am learning multiple inheritance in Python. I have two parent classes Robot and Human. They are being inherited by Cyborg class. I can access the member variable in first class i.e, Robot but unable ...
-2
votes
1
answer
131
views
Is my implementation of multiple class inheritance correct?
I have a question about multiple class inheritance in python. I think that I have already implemented it correctly, however it is somehow not in line with my usual understanding of inheritance (the ...
0
votes
1
answer
33
views
Pythonic way to pass a method to another function
I'm unsure the best way to do the following. That is, I'm not sure if I should have a parent class UniSamplingStrategy and child classes UniformSampling, and RandomSampling. Or should I just have ...
0
votes
1
answer
155
views
Double Dreadful Diamond Inheritance issue (alternative solutions allowed)
I ended up in a situation lined out below.
I have one library that is pure CPP without external libraries, and another project that is an SDK to interface with an external library.
"I" in ...
0
votes
1
answer
66
views
How can i use two extended classes in java
I am learning about java inheritance and i am a bit confused, if i write a program that handles 3 files:
1) cheese.txt
2) fruits.txt
3) drinks.txt
If i have a parent class called Food ...
1
vote
0
answers
143
views
Does this statement allow inheritance to properly work?
I'm doing a project on multilevel inheritance with a deck of playing cards. While working on the project, i received a compilation error in my program that was specifically for the suit classes (...
0
votes
0
answers
35
views
QT C++ Connect signals from derived classes [duplicate]
I am working on a class that has two parent classes:
GetSetInterface which derives QObject and
QSpinBox(which derives QObject aswell)
And I Call it SpinBoxInterface
class GetSetInterface : public ...
2
votes
2
answers
1k
views
Fix multiple inheritance with generic base classes
from typing import Generic, TypeVar, Any
R = TypeVar('R')
X = TypeVar('X')
class SizedIterator(Generic[X]):
def __init__(self) -> None:
pass
class TfmIterator(Generic[R], ...
3
votes
1
answer
2k
views
Class has no attribute of a variable from a parent class using multiple inheretance
This has probably been asked to death, but I really think this question will help someone because I really can't find a question or answer for this.
I have made an effort to boil the code down to its ...
0
votes
0
answers
31
views
Multiple inheritance with constructor arguments [duplicate]
I'm not quite sure how should it be written correctly. Can anyone help please?
class A {
public:
A(int x);
};
class B {
public:
B(float y);
};
class Launcher : public A, public B
{
...
3
votes
2
answers
2k
views
Multiple inheritance using typing module and mypy
Consider the following code:
from typing import Union
class A:
def function_in_a(self) -> str:
return 'a'
class B:
def function_in_b(self) -> str:
return "b"
class C(A, ...
1
vote
1
answer
141
views
Python Multiple Inheritance child(parent1, parent2) access parent2 __init__
let's say I have this class
class child(parent1, parent2):
pass
Would it be possible to access parent2.__init__, if parent1 also has a defined __init__ ?.
Here is my complete code.
class parent1:
...
0
votes
1
answer
64
views
can one class extends from multiple classes php
I have one class that should extend two classes I'm not sure anymore if this is possible and how. would it be possible that for example my shopModell class extends from the logins and safeinput class?
-2
votes
2
answers
174
views
How to do multiple inheritance from different classes in python using super()?
Lets say we have different kind of people, pianist,programmer and multitalented person.
so, How do i inherit like this? currently this code gives error Multitalented has no attribute canplaypiano.
...
1
vote
1
answer
53
views
Multiherence in Builder pattern
I followed this example to create a build pattern with inheritance, but in the child classes I have common fields that I would like to have in a separate class.
BaseConfiguration
...
5
votes
3
answers
1k
views
Multiple inheritance from the same interface in C#
Please consider the following program:
using System;
public interface IFoo
{
void DoFoo();
}
public class Bar: IFoo
{
public void DoFoo() => Console.WriteLine("BAR!");
}
public ...
0
votes
1
answer
417
views
Solidity Smart Contracts redundant inheritance
I'm reviewing OpenZeppelin's smart contracts and in many cases I find that there tends to be a redundant or duplicate inheritance.
contract ERC20 is IERC20, IERC20Metadata {}
interface IERC20 {}
...
0
votes
1
answer
49
views
Multiple inheretince in classes with functions that have the same name [duplicate]
If you have one class using multiple inheritance using two classes with the same name for a function, which function takes priority? From what I found the function coming first in the class ...
0
votes
0
answers
51
views
How to use multiple inheritance for implementing different comparison logic?
I am trying to use interface IComparable (not in this mockup code) and its 2 implementations to work on same object.
I must use operators to do so.
I would like to do it without resolving like here c....
0
votes
0
answers
436
views
C++ Mixins : accessing derived class method from base class method
I'm using mixins to add optional functionality to a simple base class, like so:
template<int N>
struct IntDelay
{
void setDelay(const float (&newDelays)[N])
{
for (uint i = 0; i &...
0
votes
1
answer
613
views
Overriding a virtual function but not a pure virtual function?
I'm attempting to derive a class C from two classes, A and B; after reading this answer, I attempted to write using B::<function> in order to override a pure virtual function in A with the ...