2,757 questions
Best practices
1
vote
0
replies
26
views
Calling a method from a parallel mixin in Python without breaking MRO or responsibilities
I am working on a multifunctional quite old game bot with the followng implementation:
There are tons of mixins in different files/folders (each inherits GameBase). Each mixin:
- uses attributes + ...
-1
votes
1
answer
141
views
Python and multiple inheritance [duplicate]
I tried to understand multiple inheritance behaviour with Python, so I tried something but I have no idea why the output of my code is what it is. (I know that diamond inheritance is bad, but was ...
1
vote
2
answers
199
views
What does the presence of the keyword `virtual` really do in the context of inheritance?
There are lots of posts on the internet about virtual inheritance in C++.
Typically these posts say something like this:
Virtual inheritance solves the Diamond Inheritance Problem
Virtual inheritance ...
-1
votes
2
answers
111
views
C# - Derived class that can inherit either one class OR another
This question is NOT about inheriting two classes.
This question is about inheriting ONE of two classes. One OR the other.
I have an external unchangeable DLL that provides me with two abstract ...
0
votes
1
answer
153
views
Subclass of tkinter's Toplevel class doesn't seem to inherit "tk" attribute
I'm writing a Python application using tkinter GUI.
I created the TimestampWindow class which should be one of my Windows and made it extend the Toplevel class of tkinter's library and Window, a ...
3
votes
2
answers
101
views
Template resolution in method with a class template parameter is not working when using multiple inheritance in base class. Why? How?
Consider the following code:
template<typename T>
struct Ambiguous_C {
void func(T);
};
struct Ambiguous_F {
template<typename T>
void func(T);
};
struct Conflicted_F : ...
0
votes
1
answer
85
views
How to "collect" all items associated with a chain of superclasses?
Problem
Let's say I have a hierarchy of classes where each class has an associated list of class-specific items, e.g.
class Thing:
Items = ['Exist']
class Being(Thing):
Items = ['Live', 'Die']...
1
vote
1
answer
79
views
How to fix inconsistent method resolution order when deriving from ctypes.Structure and Mapping
Given the following Python code:
import ctypes
from collections.abc import Mapping
class StructureMeta(type(ctypes.Structure), type(Mapping)):
pass
class Structure(ctypes.Structure, Mapping, ...
-1
votes
1
answer
66
views
How is super() able to (apparently) resolve to, and call, multiple methods?
I'm working on some Python code that seems like it'll be a good fit for multiple inheritance, and I'm reading about multiple inheritance and super() to make sure I correctly understand how they work.
...
0
votes
0
answers
71
views
Calling base class from 2 levels of derived class [duplicate]
I wish to call an overridden base class function from 2 or 3 levels down. For example
public class Level1
{
public virtual void Encrypt(byte[] plain)
{
Console.WriteLine("level1&...
1
vote
1
answer
65
views
How to solve this multiple inheritance properly (nice solution)
I want to call update for each derived object without a loop, this is the code that produces the loop from method "update()". How to solve it the right way?
#include <iostream>
class ...
0
votes
1
answer
72
views
Error: The request matched multiple endpoints, when I inherit from BaseController
I created a BaseController to control access to methods of all child controllers, and it is in the following code:
public class BaseController : Controller
{
protected readonly ...
2
votes
3
answers
585
views
Why does TS allow interface multiple inheritance?
I'm learning TypeScript about extending the interface. I unintentionally recognized that TypeScript allows extending interface from multiple classes. That made me surprised and I have researched a lot ...
3
votes
1
answer
358
views
Creating a metaclass that inherits from ABCMeta and QObject
I am building an app in PySide6 that will involve dynamic loading of plugins. To facilitate this, I am using ABCMeta to define a custom metaclass for the plugin interface, and I would like this custom ...
0
votes
2
answers
103
views
multiple inheritance without defining a class [duplicate]
I'm not sure that's possible, and I'm wondering if that's the way to go, or if there exists a better way of doing that.
I'll create a toy example to expose what I'm looking for.
Suppose I have people ...
2
votes
1
answer
107
views
Override function with variadic template inheritance
I have a class that inherits from 2 sets of base classes, according to variadic template arguments. One of those sets defines a virtual function. I want to do something like this but I'm not sure how ...
1
vote
1
answer
135
views
How should I write Google-Truth Subjects for an object heirarchy that uses interfaces for multiple-inheritance?
The situation
I'm writing tests for a personal project (in Java17 using JUnit5/Jupiter and Google Truth ) where I use the multiple-inheritance of interfaces to define classes. For example:
Example
...
0
votes
1
answer
40
views
How can I create an adapter that can adapt between two different data machine classes
A class that stores and handles access to some machine of type A:
class DataMachineA:
def __init__(self):
# some dummy data
self.data = {"type": ["A", "A&...
2
votes
1
answer
131
views
Why is there a difference between an operator and the corresponding member function?
Why is there a difference between the operator call and the corresponding member function call with Clang 17.0.1? Shouldn't they behave the same way?
#include <iostream>
struct A {
void ...
0
votes
1
answer
42
views
Multiple inheritance: how to correctly override a method? The complementary of the complementary of an object
TL; DR
I'm trying to implement the complementary of the complementary of a spatial region
The current solution works with a huge side effect
The solution is based on multiple inheritance. Which doesn'...
1
vote
0
answers
73
views
Cannot implement multiple inheritance with QObject
Code snippet:
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject
import sys
class ParentA:
def __init__(self, x, y):
self.b = x + y
class Child(QObject, ParentA):
...
0
votes
2
answers
89
views
C++ multiple inheritance: avoiding reimplementation of a pure virtual function if the same function is already implemented in one of the parents
I have this class hierarchy in C++:
class ISegmentReader
{
public:
virtual void readCacheFromDb() = 0;
//...
};
class ISegmentManager: public ISegmentReader
{
//readCacheFromDb not ...
2
votes
1
answer
94
views
Unexpected method call order in Python multiple inheritance
I have a child class named USA and it has two parent classes, A and B.
Both parents have a method named change_to_4 and in B.__init__ I call the method, but instead of using the method that I defined ...
0
votes
0
answers
63
views
Selective Typedefs Inheritance at Compile Time
Imagine I have a big list of typedefs that I don't want to repeat for all classes, and I create a base class:
template<class Derived>
class TypesDefs
{
using ptr = std::shared_ptr<Derived&...
0
votes
0
answers
117
views
Serializing multiple inheritance models in Django REST Framework
I have this model structure:
class Main (models.Model):
name=models.Charfield(max_length=50)
...
class Category (Main):
type=models.Charfield(max_length=50)
...
class SubCategory1(...