Skip to main content
13 votes
3 answers
1k views

The 'this' pointer in multiple inheritance of a C++ class

#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
  • 313
-1 votes
1 answer
130 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 ...
SinisterMJ's user avatar
  • 3,519
-3 votes
1 answer
68 views

How do I implement multi-inheritance DUPLICATE method in Java?

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,061
1 vote
2 answers
196 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 ...
user2138149's user avatar
  • 18.6k
0 votes
0 answers
114 views

Multiple inheritance in C++ with ambiguous (or duplicated) virtual function names [duplicate]

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.6k
-1 votes
2 answers
105 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 ...
Daniel Möller's user avatar
7 votes
2 answers
185 views

C++ class with multiple inheritance and covariant return types

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

Methods with same names in multiple inteheritance in C++ [duplicate]

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

Ruby Inheritance Chain: Reusability [closed]

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

Inheriting a Class during Construction/Initialization in Python?

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

Python initialization with multiple inheritance

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

15 30 50 per page
1
2 3 4 5
184