Do I have the correct understanding of composition
From what I read composition is when one object depends on another to exist. For example a tail cannot exist with out a dog. Also, would it 开发者_运维知识库still be considered composition if I had a tail class that was used by both a class dog and a class cat?
Yes, composition is when a large thing (think whale) eats a smaller thing (think of a poor fish of some kind).
Your cat class contains a tail just like your dog contains a tail class. Both are examples of composition.
精彩评论