+ 1

What is difference between Aggregation and composition in Object oriented programming?

Can someone explain the difference between Aggregation and composition in c++ (object oriented programming ).

30th Apr 2018, 7:38 AM
Waqas Ahmed
Waqas Ahmed - avatar
1 Antwort
+ 49
Aggregation is a form of Association where all objects have their own lifecycle, but there is ownership, and child objects can not belong to another parent object. Composition is a form of Aggregation. It is a strong type of Aggregation. Child objects do not have its lifecycle and if the parent object is deleted, all child objects will also be deleted. An example would be: A "owns" B = Composition : B has no meaning or purpose in the system without A. A "uses" B = Aggregation : B exists independently (conceptually) from A. I hope this helps and happy coding! ✌️😉 Good luck. Visit here for more information: https://stackoverflow.com/questions/885937/what-is-the-difference-between-association-aggregation-and-composition https://softwareengineering.stackexchange.com/questions/255973/c-association-aggregation-and-composition
17th Jun 2018, 12:19 AM
Ⓢ••🅢•🅣•🅐•🅡•🅢