OOP Property attribute syntax
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
John Mortensen
el 20 de Sept. de 2016
Respondida: Steven Lord
el 20 de Sept. de 2016
Hello
I've been given some code I can't quite follow and I can't seem to find any reference to an example on the net.
It is the following:
classdef classname < handle
% Read-only handle properties
properties(Access={?filename1, ?filename2, ?filename3})
prop 1
prop 2
etc...etc...
end
....etc etc
My questions are:
1) What does the "?" signify in the attribute section of the Properties call? I can't seem to search that and find an answer to it.
2) The {} brackets seem to indicate a cell array. However, I'm not sure what it's used for here though. Some documentation implies some sort of "meta class" and I haven't got a clue what that is about.
Admittedly I'm a novice in OOP and I'm really only a beginner at MATLAB as it is so I'm a bit lost here.
Any help would be appreciated. A real good clear example using this syntax would be of great help.
jom
0 comentarios
Respuesta aceptada
Steven Lord
el 20 de Sept. de 2016
The syntax ?<name of class> creates a meta.class object, which is an object that contains information (metadata) about a MATLAB class. In this context, as the value for a property's Access attribute, they indicate that only methods of certain classes (the classes whose meta.class objects you specify) are allowed to get and/or set those properties.
This technique of restricting property access is a bit of an advanced maneuver, but the examples on this page may be simple enough to show you what's going on.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Whos en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!