|
uses the keyword inherited, there is no need to supply the name of the method to call.
Events are particularly important to component developers, since they provide a hook for the user of the component to modify its behaviour in a way that may not be foreseen at the time the component is written.
Constructors and Destructors
The constructor and destructor are two special types of methods. The constructor initializes a class instance (allocates memory initialized to 0) and returns a reference (pointer) to the object. The destructor deallocates memory used by the object (but not the memory of other objects created by the object).
Classes descended from TObject have a static constructor, Create, and a virtual destructor Destroy.
TComponent introduces a new public property, the Owner of the component and this must be initialized in the constructor. TComponent''''s constructor is declared virtual, i.e. it can be overridden in descendant classes.
It is essential when you override a virtual constructor or destructor in a TComponent descendant to include a call to the inherited method.
Bibliography
- Design Patterns: Elements of Reusable Object-Oriented Software, Erich Gamma et al., Addison-Wesley, Massachusetts, 1995.
- Object Models: Strategies, Patterns and Applications, Peter Coad et al., Prentice-Hall, New Jersey, 1995.
Copyright © 1996, Objective Software Technology Pty Limited. This paper may be freely distributed in its entirety, providing the source is acknowledged.
Portions quoted from Design Patterns are Copyright © 1995, Addison Wesley Publishing Company.
上一页 [1] [2] [3] [4] [办公软件]在Excel中插入时间/日期TODAY和NOW函数 [网络安全]激活型触发式AutoRun.inf病毒和rose病毒的清除方案 [Web开发]asp.net c#其它语句之break、continue、goto实例介… [Web开发]一大堆常用的超强的正则表达式及RegularExpressio… [平面设计]制作动态GIF图像的好帮手─Coffee GIf Animator [平面设计]功能超强的GIF动画制作软件─Ulead Gif Animator [平面设计]AutoCAD常用快捷命令(外加中文说明) [平面设计]AutoCAD常用快捷命令(字母类,外加中文说明) [平面设计]AutoCAD快捷命令介绍 [平面设计]多种方法解决AutoCAD打印时出现错误
|