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!