Retrieve constant property from class handle reference
显示 更早的评论
I have a class myClass which inherits from the handle object and has a constant property:
classdef myClass < handle
properties(Constant)
myProp = 'abc';
end
end
I have a reference to the class: ref = @myClass
How do I retrieve 'myProp' from 'ref' without instantiating the class?
回答(1 个)
Adam
2017-12-7
myClass.myProp
will give you the constant property, you don't need an instance of it.
ref = @myClass
is a function handle to the constructor of the class, not a reference to the class, but either way is irrelevant to getting a constant property.
2 个评论
Chris Warwick
2017-12-11
Guillaume
2017-12-11
Matlab does not really have references. It would much easier to help you if we knew what it is you're trying to achieve.
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB Classes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!