打印本文 打印本文 关闭窗口 关闭窗口
Introduction to Design Patterns in Delphi
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3487  更新时间:2009/4/23 18:42:47  文章录入:mintao  责任编辑:mintao
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

  1. Design Patterns: Elements of Reusable Object-Oriented Software, Erich Gamma et al., Addison-Wesley, Massachusetts, 1995.
  2. 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] 

打印本文 打印本文 关闭窗口 关闭窗口