The create() constructor is made virtual in TComponent. Anything earlier
has a static constructor which you have to hide (replace), TComponent and
descendants simply use:
public
constructor Create(AOwner: TComponent); override;
published
...
constructor TAnotherComponent.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
CreateMyStuff;
blah1;
blah2;
end;
destructor TAnotherComponent.Destroy;
begin
DestroyMyStuff;
inherited Destroy;
end;
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Patrick Dunford
Sent: Tuesday, 24 August 1999 00:08
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Override
So what will happen in my code example (I am now using TPersistent and have
overridden its Assign method, incidentally)
Because that is the actual code I am using. I need the constructor to
create
X or does this happen anyway?
snip
> > Let's say I have a class declared as follows
> >
> > type A = class(TObject)
> > X: TStringList
> > constructor Create; override;
> > destructor Destroy; override;
> > end;
> >
> > constructor A.Create;
> > begin
> > inherited Create;
> > X:=TStringList.Create;
> > end;
> >
> > destructor A.Destroy;
> > begin
> > X.Free;
> > inherited Destroy;
> > end;
> >
> > Now I know that the default constructor for TObject will not
> > allocate space
> > to X so it seems logical to override the default constructor
> with my own,
> > and call the inherited constructor within that. Ditto the destructor to
> > deallocate X.
> >
> > Except that the keyword override next to my declared constructor and
> > destructor causes an error message about overriding a static
> method. So I
> > leave out the override keyword and it compiles.
> >
> > But what is the difference?
> >
> > ============================================
> > Patrick Dunford, Christchurch, NZ
> > http://patrick.dunford.com/
> >
> > ------------------------------------------------------------------
> > ---------
> > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> >
>
> ------------------------------------------------------------------
> ---------
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz