OOP Property attribute syntax
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Steven Lord
2016년 9월 20일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Whos에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!