Object Oriented Programming 9 + 10
Object Oriented Programming 9 + 10
ORIENTED
PROGRAMMING
Lecture 9 + 10
Instructor: Tayyba Khalid
Content:
■ School(Teacher* t) {
int main() {
■ teacher = t; Teacher t1("Mr. Ali");
School s(&t1); // School uses existing Teacher object
■ }
s.showTeacher();
■ }
■ };
Composition (Strong HAS-A
relationship)
Definition:
• Composition means one class owns another class.
• It represents strong ownership.
• If the container is destroyed, the contained object is also destroyed.