Subclassing Multiple Classes
In this section...
“Specify Multiple Superclasses” on page 12-22
“Class Member Compatibility” on page 12-22
“Multiple Inheritance” on page 12-23
Specify Multiple Superclasses
When inheriting from multiple classes, use the & character to indicate the combination of
the superclasses:
classdef ClassName < SuperClass1 & SuperClass2
For more information on class syntax, see “Subclass Syntax” on page 12-7.
Class Member Compatibility
When you create a subclass derived from multiple superclasses, the subclass inherits the
properties, methods, and events defined by all specified superclasses. If more than one
superclass defines a property, method, or event having the same name, there must be an
unambiguous resolution to the multiple definitions. You cannot derive a subclass from any
two or more classes that define incompatible class members.
Here are various situations where you can resolve name and definition conflicts.
Property Conflicts
If two or more superclasses define a property with the same name, then at least one of
the following must be true:
- All, or all but one of the properties must have their SetAccess and GetAccess
attributes set to private - The properties have the same definition in all superclasses (for example, when all
superclasses inherited the property from a common base class)
12 How to Build on Other Classes