The create constructor in TObject is not declared as virtual or dynamic, so
you can't override it. In fact it is not explicitly declared as anything in
particular meaning that it is static. By declaring your own create
constructor without the override your are hiding the ancestors create, not
overriding it.
---------
Copied form Delphi help
If a method declaration specifies the same method identifier and parameter
signature as an inherited method, but doesn’t include override, the new
declaration merely hides the inherited one without overriding it. Both
methods exist in the descendant class, where the method name is statically
bound. For example,
type
T1 = class(TObject)
procedure Act; virtual;
end;
T2 = class(T1)
procedure Act; // Act is redeclared, but not overridden
end;
var
SomeObject: T1;
begin
SomeObject := T2.Create;
SomeObject.Act; // calls T1.Act
end;
--------------
Hope that helps
Nahum Wild
Project Manager
Realism
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Patrick Dunford
> Sent: Monday, August 23, 1999 10:52 PM
> To: Multiple recipients of list delphi
> Subject: [DUG]: Override
>
>
> 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