【发布时间】:2013-09-23 17:09:37
【问题描述】:
考虑以下目录结构,C:\magic 是当前的 MATLAB 文件夹:
C:\magic
C:\magic\+wand
C:\magic\+hat
现在,wand 和 hat 是 MATLAB 包,可以由 import wand.* 和 import hat.* 加载。
考虑一下我可能想在+hat 文件夹中为帽子创建一个抽象类:
% C:\magic\+hat\Hat.m
classdef Hat < handle
% class implementation ...
end
还有一些子类:
% C:\magic\+hat\TopHat.m
classdef (Sealed) TopHat < Hat
% class implementation
methods
function this = TopHat()
this = this@Hat();
end
end
end
但是当我这样做时:
> import hat.*
> ha = TopHat()
我收到以下错误:
Error using hat.TopHat
The specified superclass 'Hat' contains a parse error or cannot be found
on MATLAB's search path, possibly shadowed by another file with the same name.
不过,我可以毫无错误地执行ha = Hat()。
可能发生的情况以及解决此问题的最佳方法是什么?
提前致谢!
【问题讨论】:
标签: matlab oop import package fully-qualified-naming