Hi Jose:
Original posted by Jose:
Barkat,
agregation is used to implement inheritance?
Maybe you mean that agregation can be used to get some of the benefits of inheritance: to add funtionality to a class.
It is very difficult to get to the exact intendended meaning of the authur when they use words like "aggregation" as different people mean
different things.
I think there are two sheds of meaning for aggregation:
1. within the context of a class, otherwise known
as composition, which is what I was trying to get
at in my first post. Here is a quote from Bruce Eckel's Thinking in
Java
The simplest way to reuse a class is to just use an object of that class directly, but you can also place an object of that class inside a new class. We call this “creating a member object.” Your new class can be made up of any number and type of other objects, in any combination that you need to achieve the functionality desired in your new class. Because you are composing a new class from existing classes, this concept is called composition (or more generally, aggregation). Composition is often referred to as a “has-a” relationship, as in “a car has an engine.”
2. within the context of objects i.e. containers holding objects could be termed as aggretion.
Therefore, to answer the question originally posted in this
thread: aggregation questions in exam could be related to composition and containers.
Thanks
Barkat