MATLAB Object-Oriented Programming

(Joyce) #1

Possible Values for Access to Class Members


The following class member attributes can contain a list of classes:



  • Properties — Access, GetAccess, and SetAccess. For a list of all property
    attributes, see “Property Attributes” on page 8-9.

  • Methods — Access. For a list of all method attributes, see “Method Attributes” on
    page 9-5.

  • Events — ListenAccess and NotifyAccess. For a list of all event attributes, see
    “Event Attributes” on page 11-19.


These attributes accept the following possible values:



  • public — Unrestricted access

  • protected — Access by defining class and its subclasses

  • private — Access by defining class only

  • Access list — A list of one or more classes. Only the defining class and the classes in
    the list have access to the class members to which the attribute applies. If you specify
    a list of classes, MATLAB does not allow access by any other class (that is, access is
    private, except for the listed classes).


Applications for Access Control Lists


Access control lists enable you to control access to specific class properties, methods, and
events. Access control lists specify a list of classes to which you grant access to these
class members.


This technique provides greater flexibility and control in the design of a system of classes.
For example, use access control lists to define separate classes, but not allow access to
class members from outside the class system.


Specify Access to Class Members


Specify the classes that are allowed to access a particular class member in the member
access attribute statement. For example:


methods (Access = {?ClassName1,?ClassName2,...})


Class Members Access
Free download pdf