Get a property from a class

11 ビュー (過去 30 日間)
Andrea Agostini
Andrea Agostini 2019 年 7 月 22 日
コメント済み: Andrea Agostini 2019 年 7 月 23 日
Hello,
I have a class as per attached file "ktmDbiAccess.m".
I would like the property "fullFileName" is read ony; in my understanding I have to greate a get method to do that but I cannot understand how. I have found this example but it is not clear me yet how I have to modify the class and how should I call the "get" method in the caller script.
May you please provide an example? Or just modify my class.
regards,
Andrea

採用された回答

Sean de Wolski
Sean de Wolski 2019 年 7 月 22 日
You can set the SetAccess attribute of the properties block including it to make it read-only. No reason to deal with get(), actually, it would be set(), but still unnecessary.
properties (SetAccess = private)
fullFileName
end
  1 件のコメント
Andrea Agostini
Andrea Agostini 2019 年 7 月 23 日
thanks; it works

サインインしてコメントする。

その他の回答 (1 件)

Matt J
Matt J 2019 年 7 月 22 日
編集済み: Matt J 2019 年 7 月 22 日
All you have to do is change the SetAccess property attribute, e.g.,
properties (SetAccess=private)
fullFileName
end
  1 件のコメント
Andrea Agostini
Andrea Agostini 2019 年 7 月 23 日
thanks; it works

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLanguage Support についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by