Object oriented programming problem?

4 visualizaciones (últimos 30 días)
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah el 7 de Feb. de 2019
Editada: per isakson el 19 de Feb. de 2019
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?

Respuestas (2)

Andrey Kiselnikov
Andrey Kiselnikov el 7 de Feb. de 2019
Editada: per isakson el 18 de Feb. de 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

per isakson
per isakson el 15 de Feb. de 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 comentarios
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah el 19 de Feb. de 2019
Thank you very much for your comment. \+MyPr2\+ap\+datashare are folders but Reconstruct and restore are file, that means Reconstruct.m and restore.m
per isakson
per isakson el 19 de Feb. de 2019
Editada: per isakson el 19 de Feb. de 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 &...

Iniciar sesión para comentar.

Categorías

Más información sobre Software Development Tools en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by