In Matlab, calling the superclass constructor from the derived class can be achieved using the super()
method. Here's an example:
main.m342 chars16 lines
Here, we defined a class MyClass
inherited from MySuperClass
. In the constructor of MyClass
, we called the constructor of MySuperClass
using obj@MySuperClass(arg1)
syntax.
arg1
is passed to the constructor of the superclass MySuperClass
.
If the superclass has no constructor, no super()
method is required.
Note that in Matlab, each class must have a separate file with a name that matches the class name.
gistlibby LogSnag