【发布时间】:2011-07-07 16:13:30
【问题描述】:
考虑以下 Matlab (2009a) 类:
classdef BigDeal < handle
properties
hugeness = magic(2000);
end
methods
function self = BigDeal()
end
end
end
classdef BigProxy < handle
properties(Dependent)
hugeness
end
properties(Access = private)
bigDeal
end
methods
function self = BigProxy(bigDeal)
self.bigDeal = bigDeal;
end
function value = get.hugeness(self)
value = self.bigDeal.hugeness;
end
end
end
现在考虑它们的以下用途:
设置:
>> b = BigDeal
b =
BigDeal handle
Properties:
hugeness: [10x10 double]
Methods, Events, Superclasses
单层:
>> pb = BigProxy(b)
pb =
BigProxy handle
Properties:
hugeness: [10x10 double]
Methods, Events, Superclasses
双层:
>> ppb = BigProxy(pb)
ppb =
BigProxy handle with no properties.
Methods, Events, Superclasses
问题: 为什么我的双层代理看不到hugeness 而单层代理可以看到?可以计算相关属性 - 但由于某种原因,这是否只深入一层?
更新:请参阅下面的解决方法。
【问题讨论】: