Is there a good way here to allow users to both retain access control for properties and overload indexing methods?

Assuming a member within a class has private access properties, i.e., GetAccess=private, if we use a "." type reference for that member in the overloaded subsref method, then the access property of that member becomes invalid at that point.--------------------- So, is there a good way here to allow users to both retain access control for properties and overload indexing methods?

 採用された回答

Matt J
Matt J 2023 年 9 月 3 日
編集済み: Matt J 2023 年 9 月 3 日
then the access property of that member becomes invalid at that point
Nope, not true. Even if you don't define a subsref method, private properties are still accessible through other class methods. This doesn't violate the idea of private access.
What you should be doing, probably, is to write your subsref method so that it checks whether the property is private before giving access to it.

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2020a

質問済み:

2023 年 9 月 3 日

編集済み:

2023 年 9 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by