/*
鸟继承了动物 ─△ 继承企鹅知道气候 ─> 关联
Bird拥有Wing ◆─> 合成
动物需要氧气 ┄> 依赖
雁群包含了大雁 ◇─> 聚合
WideGoose实现IFly接口 ┄△ 实现接口
*/
// 继承关系 (鸟Bird)─△(动物Animal) 鸟继承了动物
class Bird : public Animal{
};
// 关联关系 (企鹅Penguin)─>(气候Climate) 企鹅知道气候
class Penguin:Bird
{
private:
Climate climate;
};
// 合成关系 (鸟Bird)◆─>(翅膀Wing) 强拥有即 Bird拥有Wing
class Bird
{
public:
Bird()
{
wing = new Wing;
}
private:
Wing wing;
};
// 依赖关系 (动物Animal)┄>(氧气Oxygen) 动物需要氧气
class Animal
{
public:
void Metabolism(Oxygen oxygen,Water water);// 新陈代谢
};
// 聚合关系 (雁群WideGooseAggregate)◇─>(WideGoose) 弱拥有即WideGooseAggregate对象包含WideGoose,但WideGoose对象不是WideGooseAggregate对象的一部分。雁群包含了大雁
class WideGooseAggregate
{
private:
WideGoose arrayWideGoose[10];
};
// 实现接口 (大雁WideGoose)┄△(飞翔接口IFly) WideGoose实现IFly接口
class WideGoose:IFly
{
};
/*
左:
◇
◆
中:
─
┄
右:
>
△
*/