Why might you want a class to have the sealed attribute?
Mostrar comentarios más antiguos
I'm currently building my first big project relying heavily on super/subclasses for the structure of the project, so I've been learning a lot about how classes work in MATLAB.
I was looking through the class attribute page recently when I saw the 'sealed' attribute and it has me wondering what the point of it is. I understand that it prevents subclassing (and some searching on the forums seems to show that it's used for several native MATLAB classes), but my real question is why would you want to prevent that? It seems to imply that classes could be built in such a way that subclassing them could cause issues or unintended behavior, hence the desire to seal them. But I can't imagine how subclassing could cause such an issue or behavior.
So, my question would be: When should one consider using this attribute, and what kind of issues does it help avoid?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Construct and Work with Object Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!