Inheritance vs. Composition

Learn about inheritance and composition as well as their differences.

We'll cover the following...

Code reusability is a fundamental concept in object-oriented programming. We can achieve this by creating relationships between different classes. In this lesson, we will discuss two important concepts that are used for building relationships:

  • Inheritance
  • Composition

In inheritance, an object acquires the characteristics of one or more (in the case of multiple inheritances) objects. We extend the derived class from the base ...