Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Oop 如何使抽象相关属性正常工作_Oop_Matlab_Inheritance_Properties_Abstract Class - Fatal编程技术网

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属性值。