Inheritance Extending Classes: Objectives and Need for Inheritance

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Inheritance
  • This lesson discusses about inheritance, the capability of one class to inherit properties from another class as a child inherits some properties from his/her parents.
  • The most important advantage of inheritance is code reusability.
  • Once a base class is written and debugged, it can be used in various situations without having to redefine it or rewrite it.
  • Reusing existing code saves time, money and efforts of writing the code again.
  • Without redefining the old class, you can add new properties to desired class and redefine an inherited class member function.

Objectives

After going through this lesson, you would be able to

Inheritance Extending Object

Need for Inheritance

Inheritance is one of the important concepts of object-oriented language.

There are several reasons why this concept was introduced in object-oriented language. Some major reasons are:

  1. The capability to express the inheritance relationship which ensures the closeness with the real-world model.
  2. Idea of reusability, i.e.. , the new class can use some of the features of old class.
  3. Transitive nature of inheritance, i.e.. , it can be passed on further.