我已经定义了一个抽象基类measurementHandler < handle
,它定义了所有继承类的接口。该类的两个子类是a < measurementHandler
和b < measurementHandler
。
我现在有一个函数,它应该将一个句柄返回给它的调用者(取决于函数参数)。考虑这样的事情:
function returnValue = foobar(index)
if index == 0
returnValue = a();
else
returnValue = b();
end
end
此函数包含在 Simulink (2013a)中的MATLAB Function模块中。当我尝试模拟系统时,出现以下错误:
Type name mismatch (a ~= b).
任何人都可以建议一个解决方法,它仍然允许我在使用 Simulink 时利用 OOP 和继承?