http://iet.metastore.ingenta.com
1887

Constructing Simple Hierarchies with Composition

Constructing Simple Hierarchies with Composition

For access to this article, please select a purchase option:

Buy chapter PDF
£10.00
(plus tax if applicable)
Buy Knowledge Pack
10 chapters for £75.00
(plus taxes if applicable)

IET members benefit from discounts to all IET publications and free access to E&T Magazine. If you are an IET member, log in to your account and the discounts will automatically be applied.

Learn more about IET membership 

Recommend Title Publication to library

You must fill out fields marked with: *

Librarian details
Name:*
Email:*
Your details
Name:*
Email:*
Department:*
Why are you recommending this title?
Select reason:
 
 
 
 
 
A Guide to MATLAB® Object-Oriented Programming — Recommend this title to your library

Thank you

Your recommendation has been sent to your librarian.

There is another common form of inheritance, very different from parent-child inheritance, called composition. Using an object in composition is easy. All you have to do is assign an object as the value for a private member variable. For example, if double represents a class, we could say that this.mSize is one element of the composition. This means that even simple classes use a composition of built-in types. Complex classes add structures and objects to the composition. Unlike parent-child inheritance where the parent's interface is public, the interface of every object in the composition remains private. In MATLAB, there is overlap between parent-child inheritance and composition. Parent-child inheritance is a special case of composition. The child is a primary object and the parent is a secondary object. This might seem backward but it is consistent with the way primary and secondary were defined. The parent is a secondary object because the parent object is stored as an element in the child's private structure.

Chapter Contents:

  • 15.1 Composition
  • 15.1.1 The cLineStyle Class
  • 15.1.1.1 cLineStyle's private/ctor_ini
  • 15.1.1.2 cLineStyle's fieldnames
  • 15.1.1.3 cLineStyle's get
  • 15.1.1.4 cLineStyle's set
  • 15.1.1.5 cLineStyle's private/ctor_2
  • 15.1.2 Using a Primary cShape and a Secondary cLineStyle
  • 15.1.2.1 Composition Changes to cShape's ctor_ini.m
  • 15.1.2.2 Adding LineWeight to cShape's fieldnames.m
  • 15.1.2.3 Composition Changes to cShape's get.m
  • 15.1.2.4 Composition Changes to cShape's set.m
  • 15.1.2.5 Composition Changes to cShape's draw.m
  • 15.1.2.6 Composition Changes to cShape's Other Member Functions
  • 15.2 Test Drive
  • 15.3 Summary
  • 15.4 Independent Investigations

Inspec keywords: object-oriented programming

Other keywords: private member variable; child object; parent object; Matlab; this.mSize function; parent-child inheritance; simple hierarchy construction; parent-child composition

Subjects: Object-oriented programming

Preview this chapter:
Zoom in
Zoomout

Constructing Simple Hierarchies with Composition, Page 1 of 2

| /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch15-1.gif /docserver/preview/fulltext/books/pc/sbpc001e/SBPC001E_ch15-2.gif

Related content

content/books/10.1049/sbpc001e_ch15
pub_keyword,iet_inspecKeyword,pub_concept
6
6
Loading
This is a required field
Please enter a valid email address