What is proper and improper inheritance? Explain with an example?

Questions by tanish

Editorial / Best Answer

michaelpyles  

  • Member Since Dec-2007 | Dec 29th, 2007


Proper inheritance occurs when the derived class "IS A" specialized type of the base class.  Example Cat IS A Animal.
Improper inheritance occurs when a class is inherited from merely for code reuse, without having any other relationship.  Example Cat Inherits from Engine.  A Cat is not an engine however both an engine and a cat purr. 

Showing Answers 1 - 7 of 7 Answers

Raj

  • Sep 15th, 2007
 

Improper inheritance is when multiple base class is used and derive a class, then the class inheritance would be confusing. If the derived class cannot / possibly go to the base class, then we say improper inheritance

Proper inheritance: The derived class should be in a clear position to reach the base class.

Proper inheritance occurs when the derived class "IS A" specialized type of the base class.  Example Cat IS A Animal.
Improper inheritance occurs when a class is inherited from merely for code reuse, without having any other relationship.  Example Cat Inherits from Engine.  A Cat is not an engine however both an engine and a cat purr. 

yzesong

  • Jul 30th, 2009
 

As long as no diamond problems (improper inheritance),  single or multiple inheritance can all be proper inheritance. When usng multiple inheritance with diamond problem, you can use virtual inheritance to make the multiple inheritance a proper one.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions