Method lookup in multiple inheritance
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Class File Organization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!