setter/getter (.. set.Property get.Property).
, Matlab, setter/getter , . , , , / getter, Abstract , setter/getter.
1 ( )
Superclass
classdef (Abstract) TestClass1 < handle
properties
Prop
end
end
classdef TestClass2 < TestClass1
methods
function obj = TestClass2(PropVal)
if nargin>0
obj.Prop = PropVal;
end
end
function set.Prop(obj, val)
if ~isnumeric(val)
error('Not a number!');
end
obj.Prop = val;
end
end
end
2 ( )
Superclass
classdef (Abstract) TestClass1 < handle
properties (Abstract)
Prop
end
end
classdef TestClass2 < TestClass1
properties
Prop
end
methods
function obj = TestClass2(PropVal)
if nargin>0
obj.Prop = PropVal;
end
end
function set.Prop(obj, val)
if ~isnumeric(val)
error('Not a number!');
end
obj.Prop = val;
end
end
end