Object with auto execute procedures

北战南征 提交于 2019-12-11 09:45:24

问题


Is there a way to create an object with auto execute procedures? For example if a variable within this object has changed a private procedure kicks in and starts to do something?


回答1:


The language offers no such functionality. You have to implement it yourself.

Typically that's done by hiding the variable as a private, or better a strict private, and then ensure that all access to the variable is routed through a property. Then you can take whatever action you need in the property setter method.



来源:https://stackoverflow.com/questions/41695952/object-with-auto-execute-procedures

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!