Method lookup in multiple inheritance
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Class File Organization en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!