Virtual University of Pakistan Study forum !
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.
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.
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 firstname.lastname@example.org
plese share here your ideas
Solution of this Problem
The solution to avoid this problem is virtual inheritance so that in multiple inheritance only one copy of base class is generated as shown below instead of two separate copies.In virtual inheritance there is exactly one copy of the anonymous base class object.