MATLAB Object-Oriented Programming

(Joyce) #1
output = absMethodTwo(obj)
end
end

Use the logical value of the meta.class Abstract property to determine if the class is
abstract:

mc = ?AbsClass;
if ~mc.Abstract
% not an abstract class
end

Display Abstract Member Names

Use the meta.abstractDetails function to display the names of abstract properties or
methods and the names of the defining classes:

meta.abstractDetails('AbsClass');

Abstract methods for class AbsClass:
absMethodTwo % defined in AbsClass
absMethodOne % defined in AbsClass

Find Inherited Abstract Properties and Methods


The meta.abstractDetails function returns the names and defining class of any
inherited abstract properties or methods that you have not implemented in your subclass.
Use this function if you want the subclass to be concrete and must determine what
abstract members the subclass inherits.

For example, suppose that you create a subclass of the AbsClass class that is defined in
the previous section. In this case, the subclass implements only one of the abstract
methods defined by AbsClass.

classdef SubAbsClass < AbsClass
% Does not implement absMethodOne
% defined as abstract in AbsClass
methods
function out = absMethodTwo(obj)
...
end
end
end

12 How to Build on Other Classes

Free download pdf