{$IFDEF FPC}
{$MODE OBJFPC}
{$LONGSTRINGS ON}
{$ENDIF}
{$APPTYPE CONSOLE}
uses SysUtils;
type
PBase = ^TBase;
TBase = object
constructor Init;
destructor Done;
end;
PDescendant = ^TDescendant;
TDescendant = object(TBase)
constructor Init;
end;
constructor TDescendant.Init;
begin
Writeln(' begin TDescendant.Create');
inherited;
Writeln(' TDescendant.Create end');
end;
constructor TBase.Init;
begin
Writeln(' begin TBase.Create');
Fail;
Writeln(' TBase.Create end');
end;
destructor TBase.Done;
begin
Writeln(' TBase.Done');
end;
procedure Test;
var
P: PBase;
begin
WriteLn('begin');
P := New(PDescendant, Init);
if P = nil then
Writeln(' P is nil')
else
try
Writeln(' P is not nil!');
finally
Dispose(P, Done);
end;
WriteLn('end');
end;
begin
Test;
Readln;
end.