Programming Previous page   Next Page

Aggregation

In addition to standard inheritance, MATLAB objects support containment or aggregation. That is, one object can contain (embed) another object as one of its fields. For example, a rational object might use two polynom objects, one for the numerator and one for the denominator.

You can call a method for the contained object only from within a method for the outer object. When determining which version of a function to call, MATLAB considers only the outermost containing class of the objects passed as arguments; the classes of any contained objects are ignored.

See Example -- The Portfolio Container for an example of aggregation.


Previous page  Multiple Inheritance Example -- Assets and Asset Subclasses Next page

© 1994-2005 The MathWorks, Inc.