I have run into problems when using class inheritance in combination with packages. I think it is the same issue as already asked in MATLAB newsgroup a few years ago.
First, suppose I have a bunch of files with the following structure:
and the following conents:
-- InnerClass.m :
-- OuterClass.m :
classdef OuterClass < InnerClass
Now, being in the . directory, when I issue the command:
I get the following answer:
OuterClass with no properties.
So far, so good, it works as expected.
Let's move the classes into a package, so that we would have the following structure:
Now, being in the . directory, the command
ends up with an error. Of course, now the classes are part of package, we have to call it this way:
>> obj = package.OuterClass
But, GEEEEZ, I got another error message!!!
??? Error using ==> package.OuterClass
The specified super-class 'InnerClass' contains a parse error or cannot be found on MATLAB's search path, possibly shadowed by
another file with the same name.
QUESTION 1: Is this the expected behavior? If yes, what am I doing wrong???
Ok, so it seems that the OuterClass inside package somehow cannot see the definition of the InnerClass. Well, OK, so when I change the current working directory to be the +package directory and try to create the object from there, everything should work as in the beginning, right?
>> cd +package
>> obj = OuterClass
??? Undefined function or variable 'OuterClass'.
Question 2: Is this the expected behavior? Does the situation of the package directory being the working directory somehow change the way the source files are processed?
Question 3: I work in R2009a, is it the same in the newer versions?
I feel completely puzzled! These are really basic things and I do not understand them. Can somebody help me???
Thanks a lot,