由于 parent/child 用于继承,因此组合术语是什么?
As parent/child are for inheritance, what are the terms for composition?
我不知道在哪里问这个,但我不知道如何 google 这个。当class A继承class B时,A是child,B是Parent(或Base)。如果class C由D(s)组成,即如果C有D(s),C和D的项是什么?
我认为您是在谈论 "has-a" 或 "use-a" 关系。例如,简单来说,如果 C 的 D 为 class 属性(如 C++ 中的嵌入式 属性),则它被称为 "C has D",如果 C 仅具有指针D为属性,称为"C uses D"。
我不知道在哪里问这个,但我不知道如何 google 这个。当class A继承class B时,A是child,B是Parent(或Base)。如果class C由D(s)组成,即如果C有D(s),C和D的项是什么?
我认为您是在谈论 "has-a" 或 "use-a" 关系。例如,简单来说,如果 C 的 D 为 class 属性(如 C++ 中的嵌入式 属性),则它被称为 "C has D",如果 C 仅具有指针D为属性,称为"C uses D"。