Friday, August 30, 2002 01:34 AM
Actually the difference is a bit more blurred than the other answers might imply.
Aggregation and inheritance have quite a bit in common, the major thing being that they are both hierarchical.
The most important thing to remember when picking between the two comes down entirely to context - what makes sense for your model ? I can see that in some cases it would be entirely valid to model Car specialises Window, even though the every-day "common sense" approach would say it's an aggregation.
*THE* acid test for inheritance is that if A specialises B then it is an explicit part of the model that I could use an instance of A *anywhere* I could use an instance of *B* and whilst the behaviour might be different, it would still make sense. By that test, in most cases a Car cannot inherit from a Window.
However if you were a modern architect and were building a funky new building that embedded various unusual objects in its facade, some of which were acts that acted as windows then Car inherits from Window makes a lot of sense. See what I mean about context ?