+代表公有(public)
-代表私有(private)
#代表保护(protected)
classDiagram
class Animal {
+String name
+int age
+makeSound()
}
class Dog {
+String breed
+bark()
}
class Cat {
+String color
+meow()
}
Animal <|-- Dog
Animal <|-- Cat


组合和聚合的区别
组合涉及到生命周期的管理,聚合不涉及到生命周期的管理
关系区分
依赖:A偶尔用到B(函数传参)
关联:A持续用到B(成员变量引用)
聚合:A拥有B,但不控制B的生命周期
组合:A拥有B,且控制B的生命周期