When I have nested objects, changing the parameter of one object changes the same parameter in others
Show older comments
I am working with two handle classes, Class1 and Class2, defined as follows:
classdef Class1 < handle
properties
a = Class2;
end
end
classdef Class2 < handle
properties
b = 1;
end
end
If I create two separate instances of Class1 and adjust the value of parameter 'b' in the nested instance of Class2, the value of 'b' in both instances of Class 1 change. Is this supposed to happen?
Accepted Answer
More Answers (0)
Categories
Find more on Class Introspection and Metadata in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!