MATLAB Object-Oriented Programming

(Joyce) #1

  • The handles refer to the same object: == and isequal return true.

  • The handles refer to objects of the same class that have the same values, but are not
    the same objects — only isequal returns true.


Use the previously defined NumHandle class to create an object and copy the handle.


a = NumHandle;
b = a;


Test for equality using == and isequal.


a == b


ans =


1


isequal(a,b)


ans =


1


Create two instances of the NumHandle class using the default values.


a = NumHandle;
b = NumHandle;


Determine if a and b refer to the same object.


a == b


ans =


0


Determine if a and b have the same values.


isequal(a,b)


ans =


1


Comparison of Handle and Value Classes
Free download pdf