MATLAB Object-Oriented Programming

(Joyce) #1

a =


No


b = Bool.off


b =


No


Superclass Constructor Returns Underlying Value


The actual underlying value associated with an enumeration member is the value
returned by the built-in superclass. For example, consider the Bool class defined with
constructor arguments that are of class double:


classdef Bool < logical
enumeration
No (0)
Yes (100)
end
end


This class derives from the built-in logical class. Therefore, underlying values for an
enumeration member depend only on what value logical returns when passed that
value:


a = Bool.Yes


a =


Yes


logical(a)


ans =


1


How to Subclass Numeric Built-In Classes


The FlowRate enumeration class defines three members, Low, Medium, and High.


classdef FlowRate < int32
enumeration


Enumerations Derived from Built-In Types
Free download pdf