OOP: object setting property in a method without overriding object in workspace

1 view (last 30 days)
Let's say I have class pizza with properties pepperoni. Then i have method combo1 that sets pepperoni = 1;
Ok that was easy, but now in the workspace I type...
pizza1=pizza; %creates object
pizza1.combo1;
so now pepperoni should be equal to 1....
nope, pizza1.pepperoni is not 1.
how do I do this without resaving the object to pizza1?
ex pizza1=pizza1.combo1; pizza1.pepperoni1=;

Accepted Answer

Walter Roberson
Walter Roberson on 3 Apr 2012
Derive from the handle class.
  4 Comments
Honglei Chen
Honglei Chen on 3 Apr 2012
Oh I see, I misread Richard's post, I didn't realize pizza is the class constructor, I thought it's an incidence.

Sign in to comment.

More Answers (1)

Honglei Chen
Honglei Chen on 3 Apr 2012
In your combo1 method, do
functon obj = combo1(obj)
obj.pepperoni = 1;
end

Categories

Find more on Software Development Tools 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!