Why isn't permitted to derive a class from two different classes that are in turn derived from class 'matlab.mixin.Heterogeneous'?
4 views (last 30 days)
Show older comments
MathWorks Support Team
on 2 Aug 2021
Answered: MathWorks Support Team
on 2 Aug 2021
It is sought to have a class diagram, where multiple inheritance is used for classes that are derived from the 'matlab.mixin.Heterogeneous' class. However, when trying to instantiate an object from these derived classes, the following error message is asserted,
Error using myDerivedClass
Class 'myDerivedClass' has two or more direct superclasses derived from
matlab.mixin.Heterogeneous, which is not permitted.
Why isn't permitted to derive a class from two different classes that are in turn derived from class 'matlab.mixin.Heterogeneous'?
Accepted Answer
MathWorks Support Team
on 2 Aug 2021
This is the expected behavior of the software, see the following documentation page for more information,
where in the section about "Restrictions on Heterogeneous Array Formation" it is mentioned that,
"You can form heterogeneous arrays with objects that derive from multiple superclasses, but only one branch in the hierarchy can define a heterogeneous root."
0 Comments
More Answers (0)
See Also
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!