Why isn't permitted to derive a class from two different classes that are in turn derived from class 'matlab.mi​xin.Hetero​geneous'?

4 views (last 30 days)
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
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."

More Answers (0)

Categories

Find more on Construct and Work with Object Arrays in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!