Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 71181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:50:51+00:00 2026-05-10T19:50:51+00:00

I can see people asking all the time whether multiple inheritance should be included

  • 0

I can see people asking all the time whether multiple inheritance should be included into the next version of C# or Java. C++ folks, who are fortunate enough to have this ability, say that this is like giving someone a rope to eventually hang themselves.

What’s the matter with multiple inheritance? Are there any concrete samples?

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:50:51+00:00Added an answer on May 10, 2026 at 7:50 pm

    The most obvious problem is with function overriding.

    Let’s say have two classes A and B, both of which define a method doSomething. Now you define a third class C, which inherits from both A and B, but you don’t override the doSomething method.

    When the compiler seed this code…

    C c = new C(); c.doSomething(); 

    …which implementation of the method should it use? Without any further clarification, it’s impossible for the compiler to resolve the ambiguity.

    Besides overriding, the other big problem with multiple inheritance is the layout of the physical objects in memory.

    Languages like C++ and Java and C# create a fixed address-based layout for each type of object. Something like this:

    class A:     at offset 0 ... 'abc' ... 4 byte int field     at offset 4 ... 'xyz' ... 8 byte double field     at offset 12 ... 'speak' ... 4 byte function pointer  class B:     at offset 0 ... 'foo' ... 2 byte short field     at offset 2 ... 2 bytes of alignment padding     at offset 4 ... 'bar' ... 4 byte array pointer     at offset 8 ... 'baz' ... 4 byte function pointer 

    When the compiler generates machine code (or bytecode), it uses those numeric offsets to access each method or field.

    Multiple inheritance makes it very tricky.

    If class C inherits from both A and B, the compiler has to decide whether to layout the data in AB order or in BA order.

    But now imagine that you’re calling methods on a B object. Is it really just a B? Or is it actually a C object being called polymorphically, through its B interface? Depending on the actual identity of the object, the physical layout will be different, and its impossible to know the offset of the function to invoke at the call-site.

    The way to handle this kind of system is to ditch the fixed-layout approach, allowing each object to be queried for its layout before attempting to invoke the functions or access its fields.

    So…long story short…it’s a pain in the neck for compiler authors to support multiple inheritance. So when someone like Guido van Rossum designs python, or when Anders Hejlsberg designs c#, they know that supporting multiple inheritance is going to make the compiler implementations significantly more complex, and presumably they don’t think the benefit is worth the cost.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking at examples about socket programming, we can see that some people use AF_INET
Everywhere I see, can't find any info about it. I need that people who
OK I see a lot of people asking about passing other values, URLS, random
I see several people saying that WPF can use Custom Type Descriptors for Change
I see a bunch of other people asking this same question, but none of
I can see the Graphical Layout of the XML file within the /res/layout folder,
I can see it looks like an alias for an unsigned int pointer, right?
I can see where svn:keywords like Id, LastChangedDate and Author are used and replaced
I can see how to change the fonts and colors in the IDE. Is
I can see that GD library is for images. But I can't see differences

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.