具有自动执行程序的对象 [英] Object with auto execute procedures

查看:60
本文介绍了具有自动执行程序的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用自动执行过程创建对象?例如,如果此对象中的变量已更改,则私有过程会启动并开始执行某些操作?

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?

推荐答案

该语言不提供此类功能.您必须自己实施.

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

通常,这是通过将变量隐藏为 private 或更佳的 strict private 来完成的,然后确保通过属性路由对变量的所有访问.然后,您可以在属性设置器方法中采取所需的任何操作.

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.

这篇关于具有自动执行程序的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆