unit 3 opps
1️⃣ Relationships in OOP In Object-Oriented Programming, objects and classes are connected through relationships . Main types: Inheritance (IS-A) Association (Uses/Has-A) Aggregation (Has-A, weak form) Composition (strong Aggregation – optional mention) 2️⃣ Inheritance 🔹 Definition Inheritance is a mechanism by which one class acquires the properties and behavior of another class. 👉 It promotes code reusability . 🔹 Purpose of Inheritance ✅ Code Reuse ✅ Extensibility ✅ Logical hierarchy ✅ Polymorphism support ✅ Reduces redundancy 🔹 Syntax in C++ class Parent { // base class }; class Child : public Parent { // derived class }; 🔹 “IS-A” Relationship Inheritance represents an IS-A relationship . Example: Dog IS-A Animal Car IS-A Vehicle So, Dog inherits from Animal . 🔹 Example in C++ #include <iostream> using namespace std ; class Animal { public : void eat() { cout << "Animal is eati...