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 7 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.