MATLAB Object-Oriented Programming

(Joyce) #1

Attribute Specification


In this section...
“Attribute Syntax” on page 5-22
“Attribute Descriptions” on page 5-22
“Attribute Values” on page 5-23
“Simpler Syntax for true/false Attributes” on page 5-23

Attribute Syntax


Attributes modify the behavior of classes and class components (properties, methods, and
events). Attributes enable you to define useful behaviors without writing complicated
code. For example, you can create a read-only property by setting its SetAccess
attribute to private, but leaving its GetAccess attribute set to public:

properties (SetAccess = private)
ScreenSize = getScreenSize
end

All class definition blocks (classdef, properties, methods, and events) support
specific attributes. All attributes have default values. Specify attribute values only in
cases where you want to change from the default value to another predefined value.

NoteSpecify the value of a particular attribute only once in any component block.

Attribute Descriptions


For lists of supported attributes, see:


  • “Class Attributes” on page 6-6

  • “Property Attributes” on page 8-9

  • “Method Attributes” on page 9-5

  • “Event Attributes” on page 11-19


5 Class Definition—Syntax Reference

Free download pdf