OOP Relationships Explained

Association, Composition, Aggregation & Inheritance

Diagram: OOP Relationships Explained

One of the advantages of Object-Oriented programming language is code reuse. This reusability is possible due to the relationship between the classes.

One of the advantages of Object-Oriented programming language is code reuse. This reusability is possible due to the relationship between the classes. Object oriented programming generally support 4 types of relationships.

Types of Relationships

  • Inheritance - "is a" relationship
  • Association - "has-a" relationship
  • Composition - "part-of" relationship (strong)
  • Aggregation - "part-of" relationship (weak)

💡 Tip: For more details, visit: https://www.onlinebuff.com/article_understanding-the-relationships-inheritance-association-aggregation-and-composition-in-c_20.html