During the majority of development under Delphi you will not
really find the virtual constructor issue raised but there are 2 cases
I can think of
Overloaded constructors where a parameterised constructor on the base
class refers to another constructor to perform initialisation (which would
then need to be virtual)...
The second is where a class reference variable is used to perform construction
as in the VCL. (I see that Dennis Chuah has covered this case)...
type
TBase = class(TPersistent)
public
constructor Create; virtual;
constructor Create(O :TBase);
procedure Assign(Source :TPersistent); override;
end;
TBaseClass = class of TBase;
TChild = class(TBase)
public
constructor Create; override;
procedure Assign(Source :TPersistent); override;
end;
implementation
constructor TBase.Create;
begin
inherited;
// ...
end;
constructor TBase.Create(O :TBase);
begin
Create; // This is virtual so will call the correct version.
Assign(O);
end;
constructor TChild.Create;
begin
inherited;
// ...Do the newstuff
end;
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz