Oop 如何使抽象相关属性正常工作
我想在这样一个抽象类中定义一个具有属性的接口Oop 如何使抽象相关属性正常工作,oop,matlab,inheritance,properties,abstract-class,Oop,Matlab,Inheritance,Properties,Abstract Class,我想在这样一个抽象类中定义一个具有属性的接口 classdef A properties (Abstract = true) Valid; end end classdef B < A properties (Dependent = true) Valid; end methods function v = get.Valid(obj) v = 1; end
classdef A
properties (Abstract = true)
Valid;
end
end
classdef B < A
properties (Dependent = true)
Valid;
end
methods
function v = get.Valid(obj)
v = 1;
end
end
end
使用这样的接口实现
classdef A
properties (Abstract = true)
Valid;
end
end
classdef B < A
properties (Dependent = true)
Valid;
end
methods
function v = get.Valid(obj)
v = 1;
end
end
end
有人能告诉我我做错了什么吗?试着在基类中设置
Dependent
属性:
classdef A
properties (Abstract = true, Dependent = true)
Valid;
end
end
根据报告:
具体的子类必须在没有
抽象属性设置为true
按照我的理解,子类属性必须与基类匹配(没有
Abstract
属性)谢谢,这确实解决了问题。我想是文档没有提到短语中的Dependent
属性,这让我很吃惊。。。如果抽象属性未设置为true,则必须使用与基类相同的SetAccess和GetAccess属性值。