Friend Function implementation in MATLAB

15 次查看(过去 30 天)
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
编辑:Pavan Sahith 2024-8-2
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
编辑:Aquatris 2024-8-1
You can use the Access List property. Here is more explanation. Here also.

类别

Help CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by