.... How to Find Your Subject Study Group & Join ....   .... Find Your Subject Study Group & Join ....  

We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>

Study Groups By Subject code Wise (Click Below on your university link & Join Your Subject Group)

[ + VU Study Groups Subject Code Wise ]  [ + COMSATS Virtual Campus Study Groups Subject Code Wise ]

Looking For Something at vustudents.ning.com?Search Here

Graded Discussion Board Announced Dated: Jan 31, 17

Dear students,

The activity of Graded Discussion Board (GDB) will be conducted on February 07, 2017. Students will be able to post their comments for 48 hours only.


GDB Topic:

The main purpose of inheritance is reuse of code. Multiple-inheritance is more productive in terms of reuse of code than single inheritance. But all of this comes with a cost. Suppose we have a class Person which is inherited by Teacher and Student. Both Teacher and Student are further inherited by Teacher Assistant thus resulting in multiple-inheritance.

Click here for class diagram

Would you select multiple-inheritance in your code along with its intrinsic cost or do the other ways? Justify with solid reasons in either case.


Try to provide precise and to the point comments avoiding irrelevant details.

For any query, feel free to email at cs304@vu.edu.pk

This Content Originally Published by a member of VU Students.

Views: 5243

See Your Saved Posts Timeline

Attachments:

Replies to This Discussion

@Muhammad Usman's idea is accurate and way too precise.

Dear Students Don’t wait for solution post your problems here and discuss ... after discussion a perfect solution will come in a result. So, Start it now, replies here give your comments according to your knowledge and understandings....

Read Lacture no. 31 (Virtual Inheritance)

Idea For GDB Solution

In this question there is a diamond problem use in this diagram

Diamond problem:

The "diamond problem" is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C.

Why we use Diamond Problem:

It is called the "diamond problem" because of the shape of the class inheritance diagram in this situation. In this article, person is at the top, both teacher and student separately below it, and teacher –Assistant joins the two together at the bottom to form a diamond shape.  Because of this problem we cannot extend two classes for implementing multiple inheritance and to resolve this problem of multiple inheritance in object oriented programming we now use interfaces for implementing the functionality of multiple inheritance. As we know we do not define a function but only declare that function in an interface. So if we use interfaces we can extend one class and one or more interfaces or we can implement more than one interface at a time to use the functionality of multiple inheritance and we can escape from diamond problem.

In this question there is a diamond problem use in this diagram

Diamond problem:

The "diamond problem" is an ambiguity that arises when two classes B and C inherit from A, and class D inherits from both B and C.

Why we use Diamond Problem:

It is called the "diamond problem" because of the shape of the class inheritance diagram in this situation. In this article, person is at the top, both teacher and student separately below it, and teacher –Assistant joins the two together at the bottom to form a diamond shape.  Because of this problem we cannot extend two classes for implementing multiple inheritance and to resolve this problem of multiple inheritance in object oriented programming we now use interfaces for implementing the functionality of multiple inheritance. As we know we do not define a function but only declare that function in an interface. So if we use interfaces we can extend one class and one or more interfaces or we can implement more than one interface at a time to use the functionality of multiple inheritance and we can escape from diamond problem.

Tahir Sipra MCS 2nd  thanks for sharing 

Virtual Inheritance is the best solution for the diamond problem

CS304 GDB Solution

Attachments:

Answer: In the scenario mentioned, I would not use multiple-inheritance in my code. Because multiple-inheritance is prone to errors. The diamond problem is an example. If multiple-inheritance is used, the new Teacher-Assistant class will have two copies of many same functions that are inherited by the Teacher and Student Classes from Person Class, calling such functions results in ambiguity. 
One solution for the problem would be virtual inheritance. In virtual inheritance we use the word virtual in the deceleration of the classes and when we inherit with virtual inheritance, we are guaranteed to get only a single instance of the common base class. So this will solve many problems in our code and will be the best practice to use here.

RSS

Forum Categorizes

Job's & Careers (Latest Jobs)

Admissions (Latest Admissons)

Scholarship (Latest Scholarships)

Internship (Latest Internships)

VU Study

Other Universities/Colleges/Schools Help

    ::::::::::: More Categorizes :::::::::::

Latest Activity

BS IT 8th (LMS) liked + "Нσρε "'s discussion Sb se ziyada taqleef da kya hota hai?
15 minutes ago
+ɹǝʞɔɐɥ replied to +ɹǝʞɔɐɥ's discussion WAITING 4 PMNLS - Phase III >>>>> Laptop??
16 minutes ago
BS IT 8th (LMS) liked ٹمبکٹو's discussion Umeed mat harain kabhi bhi!!
19 minutes ago
βless!ng replied to ٹمبکٹو's discussion Real Life vs Social Life || Specially for Girls
23 minutes ago
آمنہ liked HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿)'s discussion Suno...!! Ay Mashriqi Larki
25 minutes ago
ٹمبکٹو posted discussions
36 minutes ago
ٹمبکٹو replied to HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿)'s discussion Suno...!! Ay Mashriqi Larki
1 hour ago
Jiya posted a discussion
1 hour ago
Ahsan MBS (3rd semester) posted a discussion
1 hour ago
HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿) replied to HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿)'s discussion فلاں لڑکی اتنی گوری ہے کاش میں بھی ویسی ہوتی۔۔۔
2 hours ago
HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿) replied to HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿)'s discussion فلاں لڑکی اتنی گوری ہے کاش میں بھی ویسی ہوتی۔۔۔
2 hours ago
HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿) replied to HaPpY cнαη∂α (✿◠‿◠)(◉‿◉✿)'s discussion فلاں لڑکی اتنی گوری ہے کاش میں بھی ویسی ہوتی۔۔۔
2 hours ago

Today Top Members 

Member of The Month

1. ٹمبکٹو

---, Pakistan

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

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