Composition (called “has-a) is a relationship between classes where one class has a data member that is an instance of the other class, such as “a car has a tire. When creating a program, you need to choose whether to relate classes through inheritance or composition.
king
hi all,
with regard to composition and inheritance, there is a term named as polymorphism...is it related to the above? so infact, composition is inheritance, but in my class, we usually called the method as inheritance and the sub-classes have the attributes and properties of the main class. i mean from the main-class, u will have the sub-classes and the relationship is called inheritance. hope that what i understand can be of use to you. cheers! :D
tristan17
Junior Poster in Training
51 posts since Sep 2005
Reputation Points: 10
Solved Threads: 1