Here's a simple example that does not work in the MATLAB language:
classdef Bar < handle % Bar class
properties Value end methods function self = Bar(value) self.Value = value; end end endclassdef Foo < Bar % Foo class
% No has constructor. We want to use the "Bar" constructor
end>> f = Foo(10)Error using FooToo many input arguments.
Too many input arguments.???
Ok…
>> f = Foo()Error using Bar (line 10)Not enough input arguments.Error in Foo (line 1)classdef Foo < Bar
What's going on? This is the ordinary inheritance. I would not want every time to write this:
classdef Foo < Bar methods function self = Foo(value) self = self@Bar(value); end endend
Best Answer