OOP UE LEC Composition and Aggregation
OOP UE LEC Composition and Aggregation
return 0;
}
• Aggregation is weaker relationship.
• Aggregation is weaker relationship, because aggregate object is not a
part of the container.
• Aggregate object can exist independently.
Class exercise
• Write a C++ program that has a class named Clinic which has at least three
doctors and ten patients. The clinic class also keeps the information of clinic’s
name and address. Each patient and doctor is allotted an Id which is
generated order-wise, e.g., the patient 1 is allotted the id 1, patient 2 is
allotted id 2, and so on. Similarly, the doctors are also allotted the Ids.
• The information required to be kept for a doctor include doctor’s name, Id,
and his/her specialization while the information related to a patient include
patient’s name, Id, age, and disease.
• The class clinic should take input of 3 doctors and 10 patients from user and
display that on screen.
• Implement the given problem by applying aggregation/composition.
Note: recall aggregation/composition, array of objects, constructor, static
members.
References
• C++ How to Program
By Deitel & Deitel
• The C++ Programming Language
By Bjarne Stroustrup
• Object oriented programming using C++ by Tasleem Mustafa, Imran Saeed, Tariq
Mehmood, Ahsan Raza
• https://www.tutorialspoint.com/cplusplus
• http://ecomputernotes.com/cpp/introduction-to-oop
• https://www.tutorialspoint.com/cplusplus/cpp_inheritance.htm
• https://www.guru99.com/c-loop-statement.html
• www.w3schools.com
• https://www.geeksforgeeks.org/