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

Everywhere I look I can only see people adding external jars to their Spring
Im looking to add rich-text in-place editing to a project (so people can see
I can see people doing joins in different ways select a.acc, b.acc, c.acc from
We can see in a directory files ordered by Name in Windows Explorer. If
I can see line numbers in my error logs in our development environment, in
I can see some options available: 1) Use PEAR's POP3 class --> tried it,
I can see in the postgresql logs that certain simple queries (no joins and
As you can see this is a question from a non web developer. I
As you can see below, in the constructor I'm instantiating a validation object so
As you can see here and here I'm not a good friend of asp.net

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.