Access to parent object or problem with organize class
Show older comments
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 Comments
Adam
on 27 Jan 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
on 27 Jan 2017
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!