我有一個簡單的類結構,如下所示:如何在Matlab中訪問超類的常量屬性?
classdef super < hgsetget
properties(Constant = true, Access = private)
PROP1 = 1;
PROP2 = {2 [3 4] [5 6]};
end
methods
function self = super()
// Constructor code here
// ...
end
end
end
,然後由子類繼承了像這樣。
classdef sub < super
properties
PROP3 = 7;
end
methods
function self = sub()
// Subclass constructor here
// ...
self = [email protected]();
test = self.PROP1; // I don't appear to have access to PROP1 from Super
end
end
end
我的問題是,當我嘗試進入超級財產PROP1
或PROP2
我似乎並沒有得到訪問:
沒有適當的方法,屬性或字段PROP1類子。
有沒有辦法在Matlab中訪問超級屬性?