Object oriented programming - Constructor behavior
显示 更早的评论
Hello guys,
I'm struggling to understand the behavior of constructor functions. Take the app designer as an example: "app" is the output variable of the constructor (i. e. the object that is created). Yet it is treated like a known (input) variable within the constructor although it is never defined. To my knowledge, this is not possible with all other functions where the return variable is unknown at the start and must be defined within the function. Hence my question: Why does that not apply to the constructor?
% App creation and deletion
methods (Access = public)
% Construct app
function app = XYZapp
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.XYZappUIFigure)
if nargout == 0
clear app
end
end
% more code...
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Methods 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!