Method lookup in multiple inheritance
显示 更早的评论
I defined four classes: a, b, c, and d. Class a defines a method f; class b inherits from a and overrides f; class c inherits from a; class d inherits from both b and c.
Why does calling f(d) print 'b'? What is MATLAB's method lookup mechanism?
classdef a
methods
function f(obj)
'a'
end
end
end
classdef b < a
methods
function f(obj)
'b'
end
end
end
classdef c < a
methods
end
end
classdef d < a
methods
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Class File Organization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!