Pass existing object to different class objects

Hi I have a object oriented programm so simulate different appliances.
I have a class object where the general settings of my programm are stored, so I don't have to save a lot of datas to every objec
If I store the object of my settings in the other object, do I generate everytime a "new" settingsobject and use a lot of space or will it be just a "pointer" to my existing object?
classdef appliance
properties
gens
% ...
end
methods
function obj = timeClass(gens)
%UNTITLED Construct an instance of this class
obj.gens = gens
end
% ...
end
end
gens = generalClassObject
appli = appliance(gens)

 채택된 답변

Matt J
Matt J 2023년 9월 13일
편집: Matt J 2023년 9월 13일

0 개 추천

It will be a "pointer", until you make a change to one of the shared copies. Then, the specific property variables that you change will be unshared. See also,

댓글 수: 1

Julian
Julian 2023년 9월 13일
But I use "handle" als the superclass of my settingsobject "gens" it will remain as a reference to the existing object, not a new copy of the object.
Have I understood it correct?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

제품

릴리스

R2023a

질문:

2023년 9월 13일

댓글:

2023년 9월 13일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by