- When you wish to create a single client for connecting a server.
- Handle for a GUI
Single instance of class
58 ビュー (過去 30 日間)
古いコメントを表示
Hello all! I have just started learning MATLAB and am exploring the OOPS concepts in it. Can someone guide me how to create a class and limit it with only one instance? Also can someone tell me where one can use it
0 件のコメント
採用された回答
Chirag Nighut
2019 年 7 月 4 日
In order to limit a single instance of a class you can use the persistent variables. Such type of classes are called Singleton Class. Such classes can be used
Following link should help you understand the singleton class and also its implementation:
1 件のコメント
Andreas Justin
2024 年 2 月 20 日
編集済み: Andreas Justin
2024 年 2 月 20 日
The persistent variables will be reinstantiated if you change the code of a class containing said variables. Even tough you might only change a comment somewhere within the source file (as of R2024a-pre).
Is mlock a valid way to prevent this behaviour?
Or is a constant property the better way?
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Software Development Tools についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!