When should you use multiple inheritance?

Answer Posted / neelam saini

There are three acceptable answers:- "Never," "Rarely," and "When the problem domain cannot be accurately modeled any other way."

Consider an Asset class, Building class, Vehicle class, and CompanyCar class. All company cars are vehicles. Some company cars are assets because the organizations own them. Others might be leased. Not all assets are vehicles. Money accounts are assets. Real estate holdings are assets. Some real estate holdings are buildings. Not all buildings are assets. Ad infinitum. When you diagram these relationships, it becomes apparent that multiple inheritance is a likely and intuitive way to model this common problem domain. The applicant should understand, however, that multiple inheritance, like a chainsaw, is a useful tool that has its perils, needs respect, and is best avoided except when nothing else will do.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the role of static keyword for a class member variable?

637


Mention the purpose of istream class?

635


Am studying basic c++ programming, have been given the following assignment. Design a linear program to calculate the maximum stress a material can withstand given a force and a diameter of a circle. To find the required area pi should be defined. Have most of the program sorted out but am at a loss as to how to show the calculations required. Can anyone help?

1753


What is a unnitialised pointer?

542


What is a literal in c++?

571






What do the keywords volatile and mean mutable?

617


Why we use #include conio h in c++?

606


What is enum class in c++?

723


Evaulate: 22%5 a) 2 b) 4 c) 0

678


What is c++ redistributable?

634


Refer to a name of class or function that is defined within a namespace?

627


Would you rather wait for quicksort, linear search, or bubble sort on a 200000 element array? (Or go to lunch...) a) Quicksort b) Linear Search c) Bubble Sort

645


What is a stack c++?

583


What is the role of C++ shorthand's?

685


What is flush programming?

588