Object oriented programming problem?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposte (2)
Andrey Kiselnikov
il 7 Feb 2019
Modificato: per isakson
il 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 Commenti
per isakson
il 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 Commenti
per isakson
il 19 Feb 2019
Modificato: per isakson
il 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 &...
Vedere anche
Categorie
Scopri di più su Software Development Tools in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!