In UML, composition is depicted as a filled diamond and a solid line. It always implies a multiplicity of 1 or 0..1, as no more than one object at a time can have lifetime responsibility for another object.
The more general form, aggregation, is depicted as an unfilled diamond and a solid line. The image below shows both composition and aggregation. The C++ code below shows what the source code is likely to look like.
参考:http://en.wikipedia.org/wiki/Object_composition
简单来说:
composition组合,是实心菱形,个体不可以脱离整体存在,生命周期一致
aggregation聚合,是空心菱形,个体生命周期跟整体的可以不一致
原文链接: https://www.cnblogs.com/kenkofox/archive/2010/11/23/1885836.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/17789
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!