OOP: object setting property in a method without overriding object in workspace
이전 댓글 표시
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=;
채택된 답변
추가 답변 (1개)
Honglei Chen
2012년 4월 3일
In your combo1 method, do
functon obj = combo1(obj)
obj.pepperoni = 1;
end
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!