multiple-inheritance

Why can't GCC disambiguate multiple inherited functions (yet clang can)? [duplicate]

我的梦境 提交于 2020-01-22 13:42:32
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Why do multiple-inherited functions with same name but different signatures not get treated as overloaded functions? This fails to compile in the indicated place with g++ 4.6.1: enum Ea { Ea0 }; enum Eb { Eb0 }; struct Sa { void operator()(Ea) {} }; struct Sb { void operator()(Eb) {} }; struct Sbroken : Sa, Sb {}; struct Sworks { void operator()(Ea) {} void operator()(Eb) {} }; int main() { Sworks()(Ea0);

C++ multiple inheritance and vtables

我们两清 提交于 2020-01-22 12:37:49
问题 So going back to basics, I'm trying to wrap my head around vtables and whatnot. In the following example, if I were to, say, pass a B* to some function, how does that function know to call the methods in the vtable of the C object instead of the methods from the vtable of A ? Are there two, separate VTables that are passed to that object? Are interface pointers really just vtables (since interfaces, IIRC, cannot contain property declarations)? What I'm trying to say is, up until I actually

C++ multiple inheritance and vtables

最后都变了- 提交于 2020-01-22 12:36:42
问题 So going back to basics, I'm trying to wrap my head around vtables and whatnot. In the following example, if I were to, say, pass a B* to some function, how does that function know to call the methods in the vtable of the C object instead of the methods from the vtable of A ? Are there two, separate VTables that are passed to that object? Are interface pointers really just vtables (since interfaces, IIRC, cannot contain property declarations)? What I'm trying to say is, up until I actually

Java class by default, it will implicitly extend java.lang.Object [duplicate]

社会主义新天地 提交于 2020-01-21 08:40:07
问题 This question already has answers here : Java doesn't support multiple inheritance but implicitly every class in java extends Object and allows one more [duplicate] (8 answers) Closed 4 years ago . In this tutorial (http://www.studytonight.com/java/object-and-classes) I read that a java class may optionally extend one parent class. By default, it will extend java.lang.Object. Note: important statement that i was read that Java enums extend the java.lang.Enum class implicitly, so your enum

Python multiple inheritance super function

我们两清 提交于 2020-01-17 05:36:07
问题 I am little confused about python multiple inheritance. For example if you had: class A(object): def __init__(self): print "init A" super(A, self).__init__() class B(A): def __init__(self): print "init B" super(B, self).__init__() class C(A): def __init__(self): print "init C" super(C, self).__init__() class D(C, B): def __init__(self): print "init D" super(D, self).__init__() if __name__ == '__main__': D() The method resolution order (MRO) would be D-C-B-A. Why the order is not D-C-A-B-A?

MRO in python when subclassing with multiple inheritance, using PyQt (QMainWindow) [duplicate]

半腔热情 提交于 2020-01-16 10:37:33
问题 This question already has answers here : How does Python's super() work with multiple inheritance? (14 answers) Closed 2 years ago . I recently experienced a TypeError , that I didn't understood when I was subclassing a QMainWindow with PyQt5 . When creating two classes: class Base (QMainWindow): def __init__(self): super(Base, self).__init__(None) class Base2 (object): def __init__(self, a, b): pass and then creating a Subclass of both, without any init arguments: class SubClass( Base, Base2

Can I tell which template instance class(es) my class is inheriting from?

倖福魔咒の 提交于 2020-01-13 13:52:09
问题 Given this code: template < int I > class Foo { public: int v; Foo() { v = I; } virtual ~Foo() {} }; class Bar : public Foo<0>, public Foo<3> { public: template < int I > int getValue() { return Foo<I>::v; } }; int main() { Bar b; cout << b.getValue<0>() << endl; // prints 0 cout << b.getValue<3>() << endl; // prints 3 cout << b.getValue<4>() << endl; // compiler error return 0; } Is it possible to iterate over all Foo<i> classes from which Bar inherits? We can assume that i is between 0 and

Can I tell which template instance class(es) my class is inheriting from?

℡╲_俬逩灬. 提交于 2020-01-13 13:51:12
问题 Given this code: template < int I > class Foo { public: int v; Foo() { v = I; } virtual ~Foo() {} }; class Bar : public Foo<0>, public Foo<3> { public: template < int I > int getValue() { return Foo<I>::v; } }; int main() { Bar b; cout << b.getValue<0>() << endl; // prints 0 cout << b.getValue<3>() << endl; // prints 3 cout << b.getValue<4>() << endl; // compiler error return 0; } Is it possible to iterate over all Foo<i> classes from which Bar inherits? We can assume that i is between 0 and

C++ Virtual Inheritance Memory Layout

泪湿孤枕 提交于 2020-01-12 08:23:17
问题 Virtual Inheritance Memory Layouts I am trying to fully understand what is happening under the hood in the memory with virtual inheritance and vTables/vPtrs and what not. I have two examples of code I have written and I understand exactly why they work however I just want to make sure I have the right idea in my mind, of the object memory layouts. Here are the two examples in a picture, and I just wish to know if my idea of the memory layouts involved are correct. Example 1: class Top {

Usage of multiple inheritance in Java 8

冷暖自知 提交于 2020-01-11 15:49:07
问题 Am I using a feature of Java 8 or misusing it? Refer the code and explanation below to know as to why it was chosen to be like this. public interface Drawable { public void compileProgram(); public Program getProgram(); default public boolean isTessellated() { return false; } default public boolean isInstanced() { return false; } default public int getInstancesCount() { return 0; } public int getDataSize(); public FloatBuffer putData(final FloatBuffer dataBuffer); public int getDataMode();