|
INTERVIEW QUESTIONS
PROGRAMMING LANGUAGES
C++
DETAILS
Question: When should you use multiple inheritance?
Answer: 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.
|
|
|
Category |
C++ Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 7551 users |
Added on |
7/16/2015 |
Views |
70019 |
Rate it! |
|
|
Question:
When should you use multiple inheritance?
Answer:
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. Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
What are the debugging methods you use when came across a problem?
|
View Answer
|
|
How the compilers arranges the various sections in the executable image?
|
View Answer
|
|
What are the differences between a C++ struct and C++ class?
|
View Answer
|
|
How do you know that your class needs a virtual destructor?
|
View Answer
|
|
What is the difference between new/delete and malloc/free?
|
View Answer
|
|
What happens when a function throws an exception that was not specified by an exception specification for this function?
|
View Answer
|
|
Can you think of a situation where your program would crash without reaching the breakball, which you set at the beginning of main()?
|
View Answer
|
|
What issue do auto_ptr objects address?
|
View Answer
|
|
Is there any problem with the following:
|
View Answer
|
|
Why do C++ compilers need name mangling?
|
View Answer
|
|
Is there anything you can do in C++ that you cannot do in C?
|
View Answer
|
|
What is problem with Runtime type identification?
|
View Answer
|
|
What is Pure Virtual Function? Why and when it is used ?
|
View Answer
|
|
What about Virtual Destructor?
|
View Answer
|
|
Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible ?
|
View Answer
|
Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.
View All C++ Interview Questions & Answers - Exam Mode /
Learning Mode
|