multiple-inheritance

Why should I avoid multiple inheritance in C++?

Is it a good concept to use or I can do other things in place of this? ...

Why do I have to specify my own class when using super(), and is there a way to get around it?

When using Python's super() to do method chaining, you have to explicitly specify your own class, for example: class MyDecorator(Decorator): def decorate(self): super(MyDecorator, self).decorate() I have to specify the name of my class MyDecorator as an argument to super(). This is not DRY. When I rename my ...

Visual Studio Compiler warning C4250 ('class1' : inherits 'class2::member' via dominance)

The following code generates warning C4250. My question is, what's the best solution to it? class A { virtual void func1(); } class B : public A { } class C : public A { virtual void func1(); } class D : public B, public C { } int main() { D d; d.func1(); // Causes warning } According to what I've read it should be possibl...

Multiple Inheritance Criticisms

I was investigating the concept of Multiple Inheritance (it's been almost 10 years since I have coded C++ in anger, and was simply academically interested in the concept). I found this reference on Wikipedia. One criticism of MI they list is "Not being able to explicitly inherit multiple times from a single class". I'm confused about th...

Implementing 2 Interfaces with 'Same Name' Properties

This seems like a reasonable (and maybe simple?) scenario, but how would you do the following: Lets say I have 2 interfaces: Interface ISimpleInterface string ErrorMsg { get; } End Interface Interface IExtendedInterface string ErrorMsg { get; set; } string SomeOtherProperty { get; set; } End Interface I want a class...

Binding IList<IMyInterfaceType> doesn't display members of Interfaces that IMyInterface inherits

I'm binding IList to a GridView. IMyInterface looks like public interface IMyInterface: IHasTotalHours, IHasLines { DateTime GoalStartDate { get; set; } DateTime GoalEndDate { get; set; } } I bind an instance to a Grid like this: IList<IMyInterface> instance= GetMyData(); myGrid.DataSource = instance; myGrid.DataBind(); Wh...

A use for multiple inheritance ?

Can anyone think of any situation to use multiple inheritance? Every case I can think of can be solved by the method operator AnotherClass() { return this->something.anotherClass; } ...

Subclassing classes with completely independant inheritance trees that cannot be modified

How would someone join two classes each with independant inheritance trees to bridge context boundaries, given the restrictions that nether class's inheritance trees can be modified to inherit from the other ie if a item that is an entity saved to a database lets say public class Stockitem : StockItemBase { ... } needs to be display...

How does Python's "super" do the right thing?

I'm running Python 2.5, so this question may not apply to Python 3. When you make a diamond class hierarchy using multiple inheritance and create an object of the derived-most class, Python does the Right Thing (TM). It calls the constructor for the derived-most class, then its parent classes as listed from left to right, then the grandp...

C++: Multiple inheritance + virtual function mess

I have a diamond multiple inheritance scenario like this: A / \ B C \ / D The common parent, A, defines a virtual function fn(). Is it possible for both B and C to define fn()? If it is, then the next question is - can D access both B and C's fn() without disambiguation? I'm assuming there is some syntax for this....

Derived System.Data classes

I would like to utilize classes that inherit the System.Data name space. Specifically, I would like to have classes CarColumn, CarTable, and CarSet derived from DataColumn, DataTable, and Dataset respectively. I would like to be able to add additional properities to each class. As an example this is how I would like to reference items...

[Python] Discussion of multiple inheritance vs Composition for a project (+other things)

I am writing a python platform for the simulation of distributed sensor swarms. The idea being that the end user can write a custom Node consisting of the SensorNode behaviour (communication, logging, etc) as well as implementing a number of different sensors. The example below briefly demonstrates the concept. #prewritten class Sensor...

Common Properties and Methods assigned to different subclass types

I'm working on building my own base user interface classes. On them, I want them to all have similar "common" properties and methods. I could define an interface class, but interface appears to only allow abstract methods, and no properties. I don't want to copy the otherwise exact same code to each class, but not sure how to implemen...

What are the Pros and Cons of having Multiple Inheritance?

What are the pros and cons of having multiple inheritance? And why don't we have multiple inheritance in C#? UPDATE Ok so it is currently avoided because of the issue with clashes resolving which parent method is being called etc. Surely this is a problem for the programmer to resolve. Or maybe this could be resolve simularly as SQL ...

How To Implement Shared Behavior Between Classes (Without Multiple Inheritance Of Course) in C#

UPDATE: So pretty much everyone here told me that i just need to start over again on how i designed my classes (thank you folks for your excellent answers by the way!). Taking the hint, i started doing extensive reading on the strategy pattern. I want to create behavior classes (or strategy classes) that inherit from an abstract base c...

LinFu - can't quite see how to do what I want

Just found LinFu - looks very impressive, but I can't quite see how to do what I want to do - which is multiple inheritance by mixin (composition/delegation as I'd say in my VB5/6 days - when I had a tool to generate the tedious repetitive delegation code - it was whilst looking for a C# equivalent that I found LinFu). FURTHER EDIT: TO...

How to bestow string-ness on my class?

I want a string with one additional attribute, let's say whether to print it in red or green. Subclassing(str) does not work, as it is immutable. I see the value, but it can be annoying. Can multiple inheritence help? I never used that. Inheriting only object and using self.value=str means I have to implement all string-ness messages ...

Abstract class + mixin + multiple inheritance in python

So, I think the code probably explains what I'm trying to do better than I can in words, so here goes: import abc class foo(object): __metaclass__ = abc.ABCMeta @abc.abstractmethod def bar(self): pass class bar_for_foo_mixin(object): def bar(self): print "This should satisfy the abstract method require...

How can I implement multiple inheritance amoung resources in Zend Acl?

Long story short: why does Zend ACL support multiple inheritance among roles and not resources? I have a large tree of resources that I would like to be able to grant permissions on. In the past, what I have done to represent this is creating two different trees. The first one has a generic resource of each type in a tree. The second ha...

Mixins vs. Traits

What is the difference between Mixins and Traits? According to Wikipedia, Ruby Modules are sort of like traits. How so? ...