MATLAB Object-Oriented Programming

(Joyce) #1

Some Basic Relationships


This section discusses some of the basic concepts used by MATLAB classes.

Classes

A class is a definition that specifies certain characteristics that all instances of the class
share. These characteristics are determined by the properties, methods, and events that
define the class and the values of attributes that modify the behavior of each of these
class components. Class definitions describe how objects of the class are created and
destroyed, what data the objects contain, and how you can manipulate this data.

Class Hierarchies

It sometimes makes sense to define a new class in terms of existing classes. This
approach enables you to reuse the designs and techniques in a new class that represents
a similar entity. You accomplish this reuse by creating a subclass. A subclass defines
objects that are a subset of those objects defined by the superclass. A subclass is more
specific than its superclass and might add new properties, methods, and events to those
components inherited from the superclass.

Mathematical sets can help illustrate the relationships among classes. In the following
diagram, the set of Positive Integers is a subset of the set of Integers and a subset of
Positives. All three sets are subsets of Reals, which is a subset of All Numbers.

The definition of Positive Integers requires the additional specification that members of
the set be greater than zero. Positive Integers combine the definitions from both Integers
and Positives. The resulting subset is more specific, and therefore more narrowly defined,
than the supersets, but still shares all the characteristics that define the supersets.

3 MATLAB Classes Overview

Free download pdf