Where was the empty array created?
Show older comments
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
Accepted Answer
More Answers (0)
Categories
Find more on Historical Contests 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!