chain overloading subref () and accessing child with '.'
2 次查看(过去 30 天)
显示 更早的评论
Hi All,
Am new to Matlab and having a problem overloading subsref.
In short, I have a class that wraps a container.map. I want to overload the () operator to return instances of the referenced item in the map. Then access using the '.' operator. i.e.
a = MyClass(MyEnums.Enum1).Data
However, cannot get it working..
This is my current attempt
function varargout = subsref(obj,S)
switch S(1).type
case '()'
[varargout{1:nargout}] = obj.Parameters(uint32(S(1).subs{1}));
case '.'
[varargout{1:nargout}] = builtin('subsref', obj, S(1));
end
end
Many many thanks in advance for any help
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!