multiple-inheritance

Is using implicit conversion for an upcast instead of QueryInterface() legal with multiple inheritance?

Assume I have a class implementing two or more COM interfaces (exactly as here): class CMyClass : public IInterface1, public IInterface2 { }; QueryInterface() must return the same pointer for each request of the same interface (it needs an explicit upcast for proper pointer adjustment): if( iid == __uuidof( IUnknown ) ) { *ppv ...

Polymorphic abstraction of Models and potential MI in rails?

We have Models like Supplier, Distributor, Vendor, Buyer in our schema. These entities have some common attributes ( like name, description, sales offices etc.) but mostly they have a divergent schema with different has_many :through associations ( a vendor has many stock_keeping_units , others do not) because of which they needed to be ...

__bases__ doesn't work! What's next?

The following code doesn't work in Python 3.x, but it used to work with old-style classes: class Extender: def extension(self): print("Some work...") class Base: pass Base.__bases__ += (Extender,) Base().extension() Question is simple: How can I add dynamically (at runtime) a super class to a class in Python 3.x? B...

How to simulate multiple inheritance in C#

How can I do this: Class A : DependencyObject {} Class B : DependencyObject {} Class C : A , B {} ...

C++: Cast to an interface that is not part of the base class

I have a series of classes representing "smart" map elements: MapTextElement, MapIconElement, etc. The classes are extending various Qt graphics item classes, but also provide common functionality, such as an abstract factory method that returns a property panel specialized for each class. I have declared these common methods in a pure v...

Using Qt signals and slots with multiple inheritance

I have a class (MyClass) that inherits most of its functionality from a Qt built-in object (QGraphicsTextItem). QGraphicsTextItem inherits indirectly from QObject. MyClass also implements an interface, MyInterface. class MyClass : public QGraphicsTextItem, public MyInterface I need to be able to use connect and disconnect on MyInterfa...

[C++] Diamond sub-problem: non-multiple inheritance in side branch still require class constructor

Strange problem occurred when I tried to "solve" usual diamond problem in a usual way - using virtual inheritance: A / \* both virtual B C \ / D However my base class A doesn't have default constructor, so I was to call it manually from D. However when I try to add a class E into this diamond as C-inherited A / \* both vir...

How does Python's super() work with multiple inheritance?

I'm pretty much new in Python object oriented programming and I have trouble understanding the super() function (new style classes) especially when it comes to multiple inheritance. For example if you have something like: class First(object): def __init__(self): print "first" class Second(object): def __init__(self): ...

"import" a definition of a function from a base class to implement abstract interface (multiple inheritance in C++)

Say we have a class inheriting from two base classes (multiple inheritance). Base class A is abstract, declaring a pure virtual function foo, the other base class B declares and implements a function foo of the very same signature. struct A { virtual void foo(int i) = 0; }; struct B { virtual void foo(int i) {} }; struct C : publi...

need multiple inheritance in Objective C

I want to implement a movable UIView class (view moves when you touch on it and move your finger), e.g.: @interface MovableView : UIView { some members; } -touchesBegan; -touchesMoved; @end How can I apply this code to UILabel, UIButton etc without multiple inheritance? In C++, I'd do it like this (with UIView as a virtual base to ...

Method resolution order in C++

Consider the following class hierarchy: base class Object with a virtual method foo() an arbitrary hierarchy with multiple inheritance (virtual and non-virtual); each class is a subtype of Object; some of them override foo(), some don't a class X from this hierarchy, not overriding foo() How to determine which method will be executed...

Virtual tables and virtual pointers for multiple virtual inheritance and type casting.

I am little confused about vptr and representation of objects in the memory, and hope you can help me understand the matter better. Consider B inherits from A and both define virtual functions f(). From what I learned the representation of an object of class B in the memory looks like this:[ vptr | A | B ] and the vtbl that vptr points...

Casting with multiple inheritance

If you have a void* pointer to Derived class that inherits from both BaseA and BaseB, how does the compiler cast the void* pointer to BaseA* (or BaseB*) without knowing that the void* pointer is of type Derived? ...

Is there a way to inherit properties from multiple classes in C#?

Possible Duplicate: Multiple Inheritance in C# In the following example, I want the Shirt to automatically inherit the properties of both the Material and Pigment classes. Is this even possible in C#? public class Material { public enum FabricTypes { Cotton, Wool, Polyester, Nylon } public FabricTypes Fabric { get; se...

C++ - downcasting a diamond shape inherited object without RTTI/dynamic_cast

Hi all! I'm currently working on integrating a third-party package that uses lots of RTTI stuff on a non-RTTI platform (Android). Basically, I did my own RTTI implementation but I'm stuck on a problem. The issue is that a lot of classes are having the diamond inheritance problem since all the classes derive from the same base class (ob...

Proper way to edit existing entity in tipfy

I'm using a PersonEditHandler class in tipfy to edit a Person entity. I have the get() and post() methods formed, but when I reference self.person (to check if the get method found the existing person by key), I get an 'object has no attribute' error. This is because I never initialize it in the init method since I'm inheriting from...

How do I serialize multple objects with the same base class to xml?

Here's the code I'm using. I keep getting xml document errors [Serializable] [XmlRoot("Command")] public class Command { [XmlElement("CommandType")] public CommandType CommandType { get; set; } } [Serializable] [XmlRoot("DelayCommand")] [XmlInclude(typeof(Command))] public class DelayCommand : Command { [XmlElement("Delay")...

Where is the "virtual" keyword necessary in a complex multiple inheritance hierarchy?

I understand the basics of C++ virtual inheritance. However, I'm confused about where exactly I need to use the virtual keyword with a complex class hierarchy. For example, suppose I have the following classes: A / \ B C / \ / \ D E F \ / \ / G H \...

Multiple inheritance is not supported in dotnet. But multiple interface supports?

Multiple inheritance is not supported in dotnet. But multiple interface supports. Why this kind of behaviour exists. Any specific reasons?? ...

How does multiple inheritance in Java work?

Class Object is the root of class hierarchy. Every class has Object as a superclass. So, if I am extending a API class, will it be like, multiple inheritance? Obviously, Java doesn't support multiple inheritance. How does it then work? ...