フィルターのクリア

Friend Function implementation in MATLAB

68 ビュー (過去 30 日間)
Subhajyoti
Subhajyoti 2024 年 8 月 1 日 12:12
編集済み: Pavan Sahith 2024 年 8 月 2 日 5:59
Typically, the private properties of a class are not accessible by any other class or function from outside.
But, a friend function can be granted special access to private and protected members of a class in C++.
Is there any way, I can implement this in MATLAB?
It would be really helpful if anyone could provide a sample code illustrating the implementation in MATLAB.
Thanks in advance.

採用された回答

Pavan Sahith
Pavan Sahith 2024 年 8 月 1 日 12:32
編集済み: Pavan Sahith 2024 年 8 月 2 日 5:59
Hello ,
I see that you are trying to achieve similar functionality of C++ friend functions in MATLAB.
In MATLAB, you can grant specific classes access to private properties and methods of another class by using access control lists. This might be helpful for your needs.
Referring to the following MATLAB answer post and MathWorks documentation will help

その他の回答 (1 件)

Aquatris
Aquatris 2024 年 8 月 1 日 12:24
編集済み: Aquatris 2024 年 8 月 1 日 12:26
You can use the Access List property. Here is more explanation. Here also.

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by