Defining Private and Public Fields within a Struct
15 ビュー (過去 30 日間)
古いコメントを表示
I see that in cpp you can define a struct to have private and public members. However, I do not see that option within Matlab. I know that there is option to use classes, however I would like to understand better if structs can have this as well.
2 件のコメント
Walter Roberson
2023 年 6 月 16 日
I see that in cpp you can define a struct to have private and public members.
C++ standard section reference, please.
I believe you are mistaken. I think you are talking about C++ classes, not C++ struct .
採用された回答
その他の回答 (1 件)
lazymatlab
2023 年 6 月 16 日
編集済み: lazymatlab
2023 年 6 月 16 日
As far as I know, matlab struct does not support access modifiers. Maybe you need to write a class which starts like this:
classdef myClass < handle
properties (Access = public)
public1
public2
end
properties (Access = private)
private1
private2
end
For more information: Property Attributes
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!