How to upcast an object?

In Matlab OOP, say I have a class B that inherits from A, then how do I upcast B to A without explicitly copying properties? (The cast function is for numeric values only and I'm interested in custom class objects.)

回答 (1 件)

Adam
Adam 2017 年 6 月 14 日

0 投票

You would have to implement your own converter function as far as I know, with the name of the base class to convert to.
It seems a bit over the top for conversion to the base class rather than some other class, but I don't know of another method.

カテゴリ

ヘルプ センター および File ExchangeConstruct and Work with Object Arrays についてさらに検索

質問済み:

2017 年 6 月 14 日

回答済み:

2017 年 6 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by