Skip to main content
Filter by
Sorted by
Tagged with
-3 votes
0 answers
27 views

Body: I am learning Multiple Inheritance in Python. In my code, I am initializing the parent classes by calling them explicitly by name, like this: I read that I should use super(), but when I use ...
jyotish's user avatar
  • 11
Best practices
1 vote
0 replies
29 views

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 + ...
Vova's user avatar
  • 609
14 votes
3 answers
1k views

#include <iostream> using namespace std; class Base1 { public: virtual void foo() { cout << "Base1::foo\n"; } int b1_data = 1; }; class Base2 { public: virtual void ...
SuperBald's user avatar
  • 333
-2 votes
1 answer
143 views

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 ...
SinisterMJ's user avatar
  • 3,517
-3 votes
1 answer
76 views

I have an 8-level hierarchy of classes in Java. This is useful so each abstract class implements methods that are common in the whole sub-branch of the tree. That's working fine. However, after going ...
Joe DiNottra's user avatar
  • 1,083
1 vote
2 answers
200 views

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 ...
user2138149's user avatar
  • 18.7k
-1 votes
0 answers
118 views

Let's start with a code example: #include <iostream> class Base1 { public: virtual ~Base1() {} virtual void f() { std::cout << "Base1.f()" << std::...
user2138149's user avatar
  • 18.7k
-1 votes
2 answers
115 views

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 ...
Daniel Möller's user avatar
7 votes
2 answers
187 views

I am trying to understand a compile error from the latest version of VC++. The error occurs in a class that inherits from two base classes and includes a virtual function that overrides functions in ...
Bill Greene's user avatar
0 votes
1 answer
165 views

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 ...
ela's user avatar
  • 401
2 votes
1 answer
151 views

I have a program #include <iostream> struct A { virtual char f() = 0; }; struct B { virtual char f() = 0; }; struct Derived : A, B { public: char A::f() override { return CA; } ...
Dmitry's user avatar
  • 154
3 votes
2 answers
105 views

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 : ...
Rddvldny's user avatar
2 votes
0 answers
87 views

How would be possible to re-use a full inheritance chain by changing configuration parameters? (i.e. constants) The base inheritance chain So let's say we have this inheritance chain C < B < A ...
rellampec's user avatar
  • 781
0 votes
1 answer
87 views

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']...
Alex Sotka's user avatar
0 votes
2 answers
111 views

For a minimalist example, say I have three classes: class A(): def method(self): print('A') self._method() def _method(self): pass class B(A): def _method(self): ...
HellSaint's user avatar
  • 121
1 vote
1 answer
83 views

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, ...
Markus's user avatar
  • 3,487
0 votes
3 answers
121 views

I have the following class hierarchy. The goal is for the calling code to choose either a base Foo object or a Foobar object that also provides the additional Bar functionality. class Foo: def ...
Ilya's user avatar
  • 645
-1 votes
1 answer
66 views

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. ...
Lux's user avatar
  • 353
0 votes
1 answer
276 views

I am trying to create a Dataclass for a Latitude&Longitude using inherited subclasses of Latitude and Longitude. But the order of the inherited subclasses is incorrect. from dataclasses import ...
akarich73's user avatar
0 votes
0 answers
71 views

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&...
cup's user avatar
  • 8,558
3 votes
1 answer
85 views

With a class that inherits from dict, why does str() not use dict.__str__ when dict is earlier in the MRO of the class? Python 3.10.12 (main, Sep 11 2024, 15:47:36) [GCC 11.4.0] on linux Type "...
Tniagcpm's user avatar
1 vote
1 answer
70 views

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 ...
extreme001's user avatar
2 votes
2 answers
61 views

I have the class structure below. Just ignore the minor issues such as mismatching variable names, this is not the issue here, I'll explain what is in a moment. class A: def __init__(self, a, b, c,...
a82fd72deb's user avatar
0 votes
1 answer
78 views

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 ...
Yousif Al-Zoubi's user avatar
0 votes
1 answer
68 views

I have 2 classes each implementing a specific behavior and using parent classes. Now I have a new class that needs to use either behavior but which one can only be determined during/after construction....
Flamefire's user avatar
  • 5,937
2 votes
3 answers
597 views

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 ...
LeoPkm2-1's user avatar
  • 319
1 vote
2 answers
102 views

I'm trying to design a class hierarchy in C++ where I have a base interface FooInterface with a pure virtual function foo(), and another interface FooBarInterface that should extend FooInterface and ...
HiroIshida's user avatar
  • 1,603
3 votes
1 answer
380 views

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 ...
KBriggs's user avatar
  • 1,498
1 vote
2 answers
54 views

I have the code. @startuml interface DbReader{ {abstract} read() } interface DbWriter{ {abstract} write(obj) } class DbConcrete { read() write(obj) } DbConcrete .up.|> DbReader DbConcrete .up.|...
Alexander Rakhmaev's user avatar
0 votes
2 answers
107 views

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 ...
user avatar
-1 votes
2 answers
96 views

I made this code that has 4 classes. The SpecialCharacter class has 2 bases, Hero and Enemy, both of which have Person as their base class. #include <iostream> class Person { private: char* ...
Digits's user avatar
  • 23
2 votes
1 answer
114 views

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 ...
Leonardo Faria's user avatar
1 vote
1 answer
511 views

I'm running into a problem using multiple inheritance in Python. In my code, Child class A inherits from two Parent classes, B and C, both abstract base classes. Each of the Parent classes, B and C, ...
Overtoad's user avatar
1 vote
1 answer
144 views

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 ...
GeenDutchman's user avatar
1 vote
0 answers
135 views

I want to have two different interface classes that declare signals and pure virtual slots, and have a implementation class that implements both of them and thus inherits their individual signals and ...
Punitto Moe's user avatar
0 votes
1 answer
46 views

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&...
amalelwatta's user avatar
1 vote
3 answers
89 views

I have an exercise to practice multiple inheritance and polymorphism and something is not going well. The exercise includes 4 classes I need to build: Creature char * name int age int numOfOffsprings ...
Reef Kenig's user avatar
2 votes
1 answer
131 views

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 ...
user avatar
3 votes
2 answers
100 views

I am trying to create a GUI system with C++11 where, perhaps like Godot, every "node" has a very specific purpose such as grouping other nodes, drawing a rectangle, or detecting when a ...
CreeperCrafter979's user avatar
0 votes
1 answer
49 views

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'...
tiago.seq's user avatar
5 votes
1 answer
233 views

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 classes? ...
Fedor's user avatar
  • 24.8k
1 vote
0 answers
74 views

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): ...
hamo's user avatar
  • 25
1 vote
1 answer
79 views

According to https://www.ibm.com/docs/en/i/7.5?topic=only-name-hiding, the assignment x = 0 in the following code is not ambiguous, because the declaration B::x has hidden A::x. struct A { int x; };...
xiaokaoy's user avatar
  • 1,733
0 votes
2 answers
89 views

I have this class hierarchy in C++: class ISegmentReader { public: virtual void readCacheFromDb() = 0; //... }; class ISegmentManager: public ISegmentReader { //readCacheFromDb not ...
user129186's user avatar
  • 1,268
0 votes
2 answers
111 views

I want to make multiple inheritance, making a subclass inherit from two different super classes. This subclass should have an __init__ method in which the __init__ methods of the super classes are ...
Arkeor's user avatar
  • 81
2 votes
1 answer
97 views

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 ...
Ali Rashidi's user avatar
0 votes
1 answer
128 views

Assunme I have some abstract class A. I want to cast into some other class B only if the dynamic type of A is a class that also inherits from B. Is there a good way to do this that doesn't involve ...
ILutRf7's user avatar
  • 71
0 votes
0 answers
63 views

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&...
SpeakX's user avatar
  • 427
0 votes
0 answers
47 views

as part of a practice of our Python knowledge, we are required to create a child class that inherits from A,B,C, to produce the output "The Name is Elzero". While I managed to do it using ...
ProgrammingLearner2023's user avatar
0 votes
0 answers
122 views

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(...
javistro's user avatar

1
2 3 4 5
56