I have 2 similar classes:
classdef class1 < handle
properties (Access = public)
b
end
properties (Access = private)
a
end
methods (Access = public)
function this = class1()
this.a = 1;
this.b = 1;
end
function test(this)
'Inside class'
this.a
this.b
this.a = 2;
this.b = 2;
end
end
end
And the second:
classdef class2
properties (Access = public)
b
end
properties (Access = private)
a
end
methods (Access = public)
function this = class2()
this.a = 1;
this.b = 1;
end
function test(this)
'Inside class'
this.a
this.b
this.a = 2;
this.b = 2;
end
end
end
One time I inherit from handle. Other one I don't do it. After I create such script:
solver1 = class1();
solver1.b
solver1
solver1.test()
solver1.b
solver1
solver1.test()
solver2 = class2();
solver2.b
solver2
solver2.test()
solver2.b
solver2
solver2.test()
If I debug my program step by step, I see that a and b haven't changed in the second class after solver2.test()
. But the first class these variable have changed after solver1.test()
. What resasons this issue?
I solve this problem with next way. I declare global variable into class. And after this, I can check this any variable in and out class. This is bad way, but it's work.