MATLAB Object-Oriented Programming

(Joyce) #1

methods
function obj = nonSub2(obj,AcListSub_Obj)
disp('Call m1 via subclass object:')
AcListSub_Obj.m1;
end
end


Calling the nonSub2 method results in execution of the superclass m1 method:


b = AcListNonSub;
c = AcListSub;
b.nonSub2(c);


Call m1 via subclass object:
Method m1 called


This behavior is consistent with the behavior of any subclass object, which can substitute
for an object of its superclass.


Abstract Methods with Access Lists


A class containing a method declared as Abstract is an abstract class. It is the
responsibility of subclasses to implement the abstract method using the function
signature declared in the class definition.


When an abstract method has an access list, only the classes in the access list can
implement the method. A subclass that is not in the access list cannot implement the
abstract method so that subclass is itself abstract.


See Also


Related Examples



  • “Property Access List” on page 12-36

  • “Method Access List” on page 12-37

  • “Event Access List” on page 12-38


See Also
Free download pdf