Main Question: Is this normal behaviour?
I've encountered some strange behaviour when initilizing properties of classes (child of handle):
Note: example test-script in zip-file (attachement)
classdef pokemon< handle % baseClass
%POKEMON container
% dummy example
properties moves = Moves() ; %Moves is also a (custom) class (child from handle)
level; end methods function obj = pokemon(obj) % obj.moves = Moves(); % if the property is initialized here, it
% works likes excepted.
end function getname(obj) % does nothing
end endend
When a property is initilized in the 'properties' section:
A= Pokemon; B = Pokemon;
The handle of A.moves and B.moves is the same. ( change A.moves, B.moves also changes)
If the property is initilized in the constructor (like I would normaly do), A.moves and B.moves are two different objects.
Sub-Question: Why does it behaves differently?
Best Answer