Daniel,
Cita:
Empezado por ecfisa
...conviene abstenerse de incluir métodos virtuales cuando se usa el antiguo estilo Pascal...trae aparejado problemas que ya han sido reportados en QualityCentral...
|
Revisa este código:
Código Delphi
[-]
program testD2009;
{$APPTYPE CONSOLE}
uses
SysUtils;
Type
PObject1 = ^TObject1;
TObject1 = Object
FCount : Integer;
Constructor Init;
Procedure Add; virtual;
end;
Type
PObject2 = ^TObject2;
TObject2 = Object(TObject1)
Constructor Init;
end;
Constructor TObject1.Init;
begin
FCount := 0;
Writeln('TDynArray:Init');
end;
Procedure TObject1.Add;
begin
Writeln('Add');
end;
Constructor TObject2.Init;
begin
Inherited Init;
Writeln('TObject2:Init');
end;
Var
Object1 : PObject1;
Object2 : PObject2;
begin
try
Object1 := New(PObject1,Init);
Object1^.Add;
Object2 := New(PObject2,Init);
Object2^.Add;
readln;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
end.
Tomado de :
QualityCentral-Using old style Objects in D2009 fails
El código anterior que falla en Delphi 2009 según se indica en QualityCentral, funciona correctamente en Delphi 2010 y Delphi XE6 sobre Windows x32 y Delphi XE7 sobre Windows 10 Technical Preview x32,
al parecer el problema reportado solo aplica a Delphi 2009, no obstante para desarrollos formales orientados a objetos
se debe usar el tipo Class.
Espero sea útil
Nelson.