Object oriented programming problem?
3 views (last 30 days)
Show older comments
I writing a program using object oriented programming in matlab 2016b. The program gives the following error:
Error using MyPr1.internalcode.Neural.FourDimensionData
The specified superclass 'MyPr2.ap.datashare' contains a parse error, cannot be found on MATLAB's search path,
or is shadowed by another file with the same name.
The FourDimensionData and datashare are in different folders. All are private.
The error code segment is:
classdef FourDimensionData < ...
MyPr2.ap.datashare &...
MyPr2.ap.datashare.Reconstruct &...
MyPr2.ap.datashare.restore &...
How can I solve this error?
0 Comments
Answers (2)
Andrey Kiselnikov
on 7 Feb 2019
Edited: per isakson
on 18 Feb 2019
Hi, you can check this manual https://www.ee.columbia.edu/~marios/matlab/MatlabStyle1p5.pdf . It was very useful for me, when I started oop in MATLAB. Also you should check ALL file paths in your application. I prefer to write some function like attached, that configures all file paths before execution.
function config_paths
rootDir = fileparts(which('config_paths'));
path2add{1} = rootDir;
path2add{2} = [rootDir,'folder_1'];
path2add{3} = [rootDir,'folder_2'];
% etc
end
0 Comments
per isakson
on 15 Feb 2019
MyPr2.ap.datashare, is that a folder, ...\+MyPr2\+ap\+datashare, or a classdef-file, ...\+MyPr2\+ap\datashare.m ?
Your code snippet indicates that in the folder, ...\+MyPr2\+ap\, you have a folder named, +datashare, together with a file named, datashare.m. Is that the case?
2 Comments
per isakson
on 19 Feb 2019
Edited: per isakson
on 19 Feb 2019
SuperclassName must be the name of a class. IMO: That could have been more clearly stated the documentation.
classdef FourDimensionData < ...
MyPr2.ap.datashare &... % You cannot inherit from a folder
MyPr2.ap.datashare.Reconstruct &...
MyPr2.ap.datashare.restore &...
See Also
Categories
Find more on Software Development Tools in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!