seems like a handle class nesting bug
2 次查看(过去 30 天)
显示 更早的评论
classdef IqReader < handle
properties
fid=0
end
...
end
classdef InReader < handle
properties
reader=IqFileReader()
end
...
end
classdef T1Reader < InReader
...
end
classdef T2Reader < InReader
...
end
t1=T1Reader();
t2=T2Reader();
assert(t1.reader ~= t2.reader);
In the example above (when split into files as matlab requires), t1 and t2 get the same handle class object as a reader. e.g. changing t1.reader.fid changes t2.reader.fid
This does not seem right to me.
2 个评论
Image Analyst
2023-5-21
Then edit it to correct the first post rather than post the correction as a comment.
回答(1 个)
Steven Lord
2023-5-21
Not a bug. See the "Handle Objects as Default Property Values" section on this documentation page for an expanation and an alternate approach to give each instance of the class a separate handle object as its property.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Handle Classes 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!