Access to parent object or problem with organize class
Mostrar comentarios más antiguos
Hi,
I need to attache some methods to the particular object obj. These methods stored to packages (folder with "+" in name).
Example: I create two instance of class: A and B. A require function from package +one, B require function from package +two. When I use this functions it is not time to clarify which package i need to use. It must be defined contemporaneously with construction of object. In additional, I don't want to write a lot of methods in main class. It is not right and not logical to write these methods in main class.
I think this problem can be solved like this:
obj.prop.met(a,b,c);
obj- object 1 (main class);
prop - property of obj;
anObj - another object ( obj.prop = anObj, class of this object contains methods which can access to function in packages);
met(a,b,c) - method of anObj (need obj to work);
Can method met(a,b,c) access to obj ? I tried to find answer but not found.
Can I use adress " this " to access to obj ?
What do you think about this problem? How you solve it?
Thanks for help. Sorry for my english:(
2 comentarios
Adam
el 27 de En. de 2017
I think it would be best to try to replicate as simple an example as you can and try it out (or post here). I am not really following what you are trying to do. No need to worry about your English, but it does help to try to give code examples since they are a more universal language.
When I want to try out if some fundamental operation is possible in a class setup I just create the two or three or however many classes I need to minimally test it out without anything extra in them.
Sergey Kasyanov
el 27 de En. de 2017
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!