OOP Property attribute syntax
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
John Mortensen
am 20 Sep. 2016
Beantwortet: Steven Lord
am 20 Sep. 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 Kommentare
Akzeptierte Antwort
Steven Lord
am 20 Sep. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!