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

Are there interfaces in c++?

558


What is the basic structure of a c++ program?

612


Define private, protected and public access control.

607


What is while loops?

617


Why cout is used in c++?

562






Explain what are accessor methods?

667


Can we distribute function templates and class templates in object libraries?

591


How is data hiding achieved in c++?

572


What are the restrictions apply to constructors and destructors?

643


Are iterators pointers?

677


What is a class template?

589


Is c++ a programming language?

594


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

742


What data encapsulation is in c++?

595


What is a modifier in c++?

634