Where was the empty array created?
显示 更早的评论
My understanding of classes: one of the roles of class properties is to store data.
When I run the following command,
x=Base.empty(7,0)
it shows that I've created a 7*0 Base array.
Qusetion:
1 So, is this 7*0 Base array stored in 'a,' ?in 'b'? or does 'a' and 'b' each have a separate 7*0 Base array? Why?
2 Is 'empty' a method or a function? This page shows it as a function. However, in OOP, aren't we supposed to use methods within classes? Why is 'empty' defined as a function and not a method?"
if you input mc=?Base; in command line , you will find mc.MethodList(3,1) is 'empty' method.
It seems like 'empty' is also a method, so is 'empty' actually a method or a function? Does MATLAB have the concept of class functions? If there are class functions, what is the difference between class functions and class methods?"
classdef Base
properties (Access=public)
a;
b;
end
methods
function obj=Base(value)
obj.a=value;
end
end
methods (Access=private)
function Fun(obj)
disp(num2str(obj.a));
end
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Historical Contests 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!