Latest Activity In Study Groups

Join Your Study Groups

VU Past Papers, MCQs and More

We non-commercial site working hard since 2009 to facilitate learning Read More. We can't keep up without your support. Donate.

Graded Discussion BoardDated:Feb 07, 19

Dear Students!!!

I hope you will be fine and will enjoying studies. Please note that Graded Discussion will be launched next week on Wednesday, February 13, 2019 and it will remain open for two days (13th and 14th February, 2019). You should prepare and post your comments on below mentioned topic till the end of Thursday February 14, 2019.

Graded Discussion Topic: 

A programmer can extend the functionality and re-usability of classes using Multiple Inheritance. If it is useful in C++ then why modern object oriented languages like Java, VB.NET and C# do not support multiple Inheritance. Justify your answer with solid reasons. 

Special Note: Please note that Concise and Coherent comments will be appreciated. Lengthy comments can cause deduction in marks. 


Instructor CS304

Views: 915

Replies to This Discussion

Different languages actually have different expectations for how MI works. For example, how conflicts are resolved and whether duplicate bases are merged or redundant. Before we can implement MI in the CLR, we have to do a survey of all the languages, figure out the common concepts, and decide how to express them in a language-neutral manner. We would also have to decide whether MI belongs in the CLS and what this would mean for languages that don't want this concept (presumably VB.NET, for example). Of course, that's the business we are in as a common language runtime, but we haven't got around to doing it for MI yet.
The number of places where MI is truly appropriate is actually quite small. In many cases, multiple interface inheritance can get the job done instead. In other cases, you may be able to use encapsulation and delegation. If we were to add a slightly different construct, like mixins, would that actually be more powerful?
Multiple implementation inheritance injects a lot of complexity into the implementation. This complexity impacts casting, layout, dispatch, field access, serialization, identity comparisons, verifiability, reflection, generics, and probably lots of other places.
The reasons for omitting multiple inheritance from the Java language mostly stem from the "simple, object oriented, and familiar" goal. As a simple language, Java's creators wanted a language that most developers could grasp without extensive training. To that end, they worked to make the language as similar to C++ as possible (familiar) without carrying over C++'s unnecessary complexity (simple).
In the designers' opinion, multiple inheritance causes more problems and confusion than it solves. So they cut multiple inheritance from the language (just as they cut operator overloading). The designers' extensive C++ experience taught them that multiple inheritance just wasn't worth the headache.

The problem is that the compiler/runtime cannot figure out what to do if you have a Cowboy and an Artist class, both with implementations for the draw() method, and then you try to create a new CowboyArtist type. What happens when you call the draw() method? Is someone lying dead in the street, or do you have a lovely watercolor

C# and java both doesn’t support the multiple inheritance because of the ambiguity issue. Lets take an example You have three classes A,B and C now suppose c extends the class a and b something like that
Class C extends A,B
now suppose both classes A and B have a function with the name demo(). Now if you will create the object of c class and try to call that demo function at that time compiler will get confuse weather to call demo from A or from B class. This is the reason why C# and java both doesn’t support multiple inheritance without interface.
One of the most important concepts in object-oriented programming is inheritance.It also provides an opportunity to reuse the code functionality and speeds up performance time in inheritance, the ability to create classes which inherits certain aspects from parent classes.
When we create a class, instead of writing fully new data members and member functions, the programmer can assign that the new class should inherit the members of an existing class. This existing class is called the baseclass, and the new class is referred to as the derived class.

There are couple of problems with multiple inheritance and the most obvious problem is with function overriding.

Let assume you have 2 classes A and B. both have defined function 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(); 

which implementation of the method should it use?
Without any further clarification, it's impossible for the compiler to resolve the ambiguity.
This problem is also known as Diamond Problem.

The 2nd big problem with multiple inheritance beside function over-riding is the layout of the
physical objects in memory.

For More Depth Knowledge READ This Article

Please Discuss here about this GDB.Thanks

Our main purpose here discussion not just Solution

We are here with you hands in hands to facilitate your learning and do not appreciate the idea of copying or replicating solutions. Read More>>

Discussed & be touched with this discussion. After discussion a perfect solution will come in a result at the end.


“How to Join Subject Study Groups & Get Helping Material”


P.S:    Please always try to add the discussion in proper format title like “CS101 Assignment / GDB No 01 Solution & Discussion Due Date: ___________”


Share below link with friends for solution & Discussion.


© 2021   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service