[lazarus] Order of destruction in TCustomListBox

Michael Van Canneyt michael.vancanneyt at wisa.be
Mon Dec 15 03:50:04 EST 2003




On Mon, 15 Dec 2003, Micha Nelissen wrote:

> Mattias Gaertner wrote:
>
> > On Sun, 14 Dec 2003 15:09:48 +0100  Micha Nelissen <micha at neli.hopto.org>
> > wrote:
> >><output>
> >>CB.SomeFunc call
> >>Constructor
> >></output>
> >>
> >>Which is not logical, IMHO.
> >
> >
> > It is just a matter of definition. Although it would be interesting how you
> > imagine a more logical alternative.
>
> The definition is: the object is only 'defined', if it's constructor has
> run completely. Something along those lines is used by C++. After each
> constructor run, and only then, are the overriden function pointers
> written to the VMT. Personally, I think this is more logical, although
> maybe it's a matter of personal taste.

I can show you code where in the constructor a virtual method is called
which does some additional initialization. The method needs to be
virtual since the initialization is different depending on the
descendent. That would not work in your scheme as it would be invalid
code...

You would in such case require a separate call by the programmer, after
the constructor, to do this initialization. That is not possible for
instance in streaming. The streaming system has no way of knowing that
some separate initialization is needed. This means that all
initialization must be done in the constructor...

Michael.






More information about the Lazarus mailing list