Questions tagged [multiple-inheritance]

A feature of some object-oriented computer programming languages in which a class can inherit behaviors and features from more than one superclass or base class.

Languages that support multiple inheritance include:

  • C++
  • Common Lisp (via CLOS)
  • Curl
  • Dylan
  • Eiffel
  • EuLisp (via The EuLisp Object System TELOS)
  • Logtalk
  • Object REXX
  • OCaml
  • Perl
  • Perl 6
  • Python
  • Scala (via the use of mixin classes)
  • Tcl (via Incremental Tcl)

Other object-oriented languages, such as Java and Ruby implement single inheritance, although protocols or "interfaces" provide some of the functionality of true multiple inheritance.

2710 questions
1
vote
1 answer

How to best implement this Ruby code in Python

Ruby code: module ToFile def filename "object_#{self.object_id}.txt" end def to_f File.open(filename, 'w') { |f| f.write(to_s) } end end class Person include ToFile attr_accessor :name def initialize(name) @name =…
Riina
  • 530
  • 1
  • 7
  • 19
1
vote
1 answer

what does compiler do when new an object and assign the address of the created object to its base class pointer

Example 3:(page 377) class A {virtual void f();}; class B {virtual void f(); virtual void g();}; class C: A, B {void f();}; A* pa = new C; B* pb = new C; C* pc = new C; pa->f(); pb->f(); pc->f(); pc->g() (1) In Multiple inheritance for C++, Bjarne…
Fihop
  • 3,127
  • 9
  • 42
  • 65
1
vote
0 answers

Need design help as I'm causing a diamond with multiple Inheritance

My classes currently look like this: GetAndSet{ virtual int get() = 0; virtual void set() = 0; } WindowsGetAndSet : public GetAndSet{ virtual int get(); virtual void set(); } However, I've ran into some new constraints and…
TrolliOlli
  • 909
  • 2
  • 10
  • 18
1
vote
1 answer

Multiple inheritance difference between Python 2.7 and 3

I've already got that there is a difference between Python 2.7 and 3. implementing multiple inheritance, for example: In Python 3.: class A: def __init__(self, x2='', x3='', **kwargs): print kwargs super().__init__(**kwargs) …
Reza F
  • 25
  • 6
1
vote
3 answers

can an abstract class inherit from a "normal" class?

I am looking for a useful example of multiple inheritance in C++ and found an example for Window-creation here: A use for multiple inheritance? and modified it a bit. It conceptually looks like this: class Window class Skinable // abstract class…
1
vote
1 answer

how do I allocate a pointer to a class with multiple inheritance

Suppose I have: class Human { string choice; public: Human(string); }; class Computer { string compChoice; public: Computer(string); }; class Refree : public Human, public Computer { public: string FindWinner(); }; int main()…
1
vote
1 answer

How can i inherit from all types in mpl::vector?

I use mpl::vector from boost 1.58. I have types: typedef mpl::vector types; If I have a class derived, how can i inherit it from all of these types in this mpl::vector?
D. Ermolaev
  • 148
  • 1
  • 6
1
vote
2 answers

Refactoring a leaf class to a base class, and keeping it also a interface implementation

I am trying to refactor a working code. The code basically derives an interface class into a working implementation, and I want to use this implementation outside the original project as a standalone class. However, I do not want to create a fork,…
elcuco
  • 8,948
  • 9
  • 47
  • 69
1
vote
2 answers

Multiple inheritance via templates

Is it good idea to replace virtual multiple inheritance (diamon) with teplates inheritence (linear)? For example I have this class diagram : IBase / \ / \ IExtendedBase BaseImpl \ / ExtendedImpl I…
1
vote
2 answers

Am I in a specific case justifying multiple inheritance?

Currently, I have the following classes managing different kinds of variables : class Variable; class Number : public Variable; class Boolean : public Variable; class RealNumber : public Number; class IntegerNumber : public Number; This is a…
Caduchon
  • 4,574
  • 4
  • 26
  • 67
1
vote
1 answer

Multiple-inheritance and mixins to bind object slots in Python

I am interested in creating a class hierarchy where various mixins create the slots in an object: class A(object, Keyable, Taggable): """A is keyable and taggable.""" def __init__(self): super(A, self).__init__() print…
Terrence Brannon
  • 4,760
  • 7
  • 42
  • 61
1
vote
0 answers

Function ambiguous in multiple inheritance

The following code gives error that request for member fcn1 is ambiguous. Why is this happening? class Base1 { public: void fcn1(int x) {} }; class Base2 { public: void fcn1(int x, int) {} }; class D: public Base1, public Base2 { }; int…
szli
  • 36,893
  • 11
  • 32
  • 40
1
vote
1 answer

C# Repository with multiple constraints and inheritance

i wasn't able to find a similar issue but feel free to redirect me if i just missed it. I am trying to get familiar with the Repository pattern. I'll give you an example of the code i'm trying to get to work unsuccessfully. These are the classes and…
1
vote
2 answers

Use multiple inheritance to discriminate useage roles?

it's my flight simulation application again. I am leaving the mere prototyping phase now and start fleshing out the software design now. At least I try.. Each of the aircraft in the simulation have got a flight plan associated to them, the exact…
Arne
  • 1,111
  • 2
  • 11
  • 22
1
vote
3 answers

How to give properties to c++ classes (interfaces)

I have built several classes (A, B, C...) which perform operations on the same BaseClass. Example: struct BaseClass { int method1(); int method2(); int method3(); } struct A { int methodA(BaseClass& bc) { return bc.method1(); } } struct…
caas
  • 455
  • 1
  • 5
  • 12
1 2 3
99
100