[lazarus] Order of destruction in TCustomListBox

Marc Weustink marc.weustink at cuperus.nl
Mon Dec 15 08:53:11 EST 2003


+ From: Micha Nelissen [mailto:micha at neli.hopto.org]
+ Sent: maandag 15 december 2003 14:42
+
+ Marc Weustink wrote:
+
+ > + From: michael at idefix.wisa.be
+ [mailto:michael at idefix.wisa.be]On Behalf Of
+ > + Michael Van Canneyt
+ > + Sent: maandag 15 december 2003 13:49
+ > +
+ > + On Mon, 15 Dec 2003, Micha Nelissen wrote:
+ > +
+ > + > >>The definition is: the object is only 'defined', if it's
+ > + > >>constructor has run completely. Something along those
+ > + > >>lines is used by C++.
+ >
+ > The way constructos/destructors and inherited parts in C++
+ > are complete different then in object pascal. AFAIK the parent
+ > constructor/destructor is called implicitly
+ >
+ > OK, after some talks to the "real" C++ programmers overhere
+ > it is clear that one can do the same in C++ as we do in Delphi,
+ > so there is no real difference.
+
+ There is not?

No, in the defenition part of the constructor, one can define the
initialization of the locals and the call to the inherited. The order can
be changed.

In pascal you get someting like:

constructor Create;
begin
  FItems := TList.Create;
  FCount := 0;
  inherited;
  //-------------------
  DoSomethingVirtual;
end;

Even if inherited would call someting virtual it is ok.

+ > + > >>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.
+ >
+ > Ow ? AFAIK the vmt pointers are filled in before the constructor is
+ > called.
+
+ Oops, that needs to be: after the inherited constructor has run.

Nope, before the the call to the constructor is made. The vmt is complete
on the first entry of the constructor (even before the call to
beforeconstruction)

If the vmt is filled in the constructor, one could never have virtual
constructors.

Marc







More information about the Lazarus mailing list