[lazarus] Order of destruction in TCustomListBox
Marc Weustink
marc at dommelstein.net
Sun Dec 14 09:55:17 EST 2003
At 15:10 14-12-2003, Micha Nelissen wrote:
>Marc Weustink wrote:
>
>>At 22:22 13-12-2003, Micha Nelissen wrote:
>>
>>>Mattias Gaertner wrote:
>>>
>>>>
>>>>What do you mean?
>>>
>>>
>>>I don't like the fact of pascal that it's possible that overriden
>>>functions get called although their constructor hasn't run or their
>>>destructor has run.
>>
>>That has nothing to do with object pascal, but all with the one who
>>designed the classes you're using. IMO calling virtuals in yuor
>>constructor/destructor isn't a bad thing if you know what you're doing.
>>If things has to be called in a certain order, that is nothing different
>>than programming other routines.
>
>I think you didn't understand what I was saying, please read my reply to
>Mattias for an example.
I did understand what you were saying and I had the same example in mind
when I wrote this.
From you example, I see no reason why the inherited constructor should be
called first. (OK it was necesary when using objects, but not for classes)
So in your derived class you can initialize all vars and then call inherited.
I don't see why this violates OO. You are in the constructing phase of you
object.
I've used many times abstract virtuals in my constructor, to force a
constructing order and to be able to use "user defined" classes for member
objects in derived classes.
Marc
More information about the Lazarus
mailing list