For example, car, engine. On line:
Some people think it is aggregation relationship. Because Engine can exists without car.
But some people think it is composition relationship. Because if the car is destroyed, the engine also is destroyed.
what is the right answer?
posted 6 years ago
If the engine is used in other classes as well - like Bus, aeroplane etc Then it is an aggregation. If the engine can only be associated with the Car class, and Car is responsible for instantiating/destroying the engine instance, then it is composition.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads