OOP: Object gone out of scope!
Mostra commenti meno recenti
Hi,
I have two handle classes.
In one of them I call the constructor of the other handle class many times.
Problem: Upon entering the constructor of the other class, the object of the first class is gone and I can't access it's properties unless I define an instance of the first class...
Must I pass the object of the first class to the other class or is there another way of doing this?
Class1
def Class1 < handle
properties (Constant)
f = 1:2:20
g = 1:3:30
end
properties
a_Class1
b_Class1
c_Class1
end
methods
function obj = Class1(a,b,c)
obj.a_Class1 = a;
obj.b_Class1 = b;
obj.c_Class1 = c;
for k = 1:10
x(k) = Class2(k,f(k),g(k))
end
end
end
end
The values for a,b and c are user-specific values...
I need to access the values a,b and c in Class_2 without having to pass the whole object of Class1 to Class2...
The properties a_Class1, b_Class1 and c_Class1 are the same for both classes ...
Thank you for your advice!
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Construct and Work with Object Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!